Results 1 to 3 of 3

Thread: Confirm Script Problem

  1. #1
    Join Date
    Mar 2009

    Confirm Script Problem

    I am a JS newbie so please be patient.

    I need to create a page with up to 5 addresses from a DB and an associated "graphic" delete button. If the user hits one of the delete buttons, I want to throw up a confirm box to have them confirm.

    I have a short prototype script that is OK with 1 address and an HTML "button":

    <script type="text/javascript">
    function show_confirm()
    var r=confirm("Confirm Deletion");
    if (r==true)
      window.location.href = "AMaddAddressAction.cfm?delete=1"
    <form id="test" action="AMaddAddressAction.cfm" method="post">
    <input type="text" name="user" />
    <input type="button"  name="rich"  value="Delete" onClick="show_confirm()" />
    But I'm not sure how to pass the name of the button to the function.

    Also I do not know how to do the confirm box with an image for a button

    Any ideas would be most appreciated?

    Last edited by hefterr; 10-29-2009 at 11:41 AM.

  2. #2
    Join Date
    Jul 2009
    Is good that are newbie in JavaScript, learn jQuery instead is better and easier framework than prototype.

  3. #3
    Join Date
    Dec 2008
    Using "this.name" will reference the name of the input properly from the onclick. You'll need to add some code to the function to parse this name.
    <input type="button"  name="rich"  value="Delete" onClick="show_confirm(this.name)" />
    You can also add a reference to the calling element's name into the function instead of using it as an argument in the call, using "event.srcElement".

    <script type="text/javascript">
    function showName()
    <input type="button" value="Show Name" name="FOO" onclick="showName()" />

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles