www.webdeveloper.com
Results 1 to 5 of 5

Thread: javascript confirm before submission of form

  1. #1
    Join Date
    Mar 2005
    Location
    planet earth
    Posts
    121

    Smile javascript confirm before submission of form

    i don't even know if this is possible:

    i have text, the word "Delete" as a form. i want to confirm before submission.

    i want to click, confirm, then submit. the "onsubmit" attribute of the form is being completely ignored.

    form code:

    Code:
    <form action="admin.php" method="post" name="bdel3" onsubmit="return confdelete()">
    <a href="admin.php" onclick="document.bdel3.submit(); return false">Delete</a></form>
    javascript function:

    Code:
    function confdelete() {
    	var answer = confirm("delete?")
    	if (answer) return true;
    	else return false
    }
    needless to say i'm no JS expert ^^

    any ideas gratefully received
    Last edited by hitecbill; 09-09-2008 at 07:46 AM.

  2. #2
    Join Date
    Sep 2006
    Location
    Copenhagen, Denmark
    Posts
    1,253
    Replace the link with an actual submit button. Calling the submit method of a form element does not trigger the onsubmit event.

  3. #3
    Join Date
    Mar 2005
    Location
    planet earth
    Posts
    121

    Thumbs up

    Quote Originally Posted by Dok
    Replace the link with an actual submit button. Calling the submit method of a form element does not trigger the onsubmit event.
    lovely, works a treat..spot on m8.

    thx for your help Dok



    just out of a pedantic interest, would it be possible to create a rollover for the submission button? (i doubt it)

    i.e. just to spoof the underline rollover of text?

    it's only for a non-public facing content admin page of a client site, so it's not important but was jus' wonderin'?


    just as an after question, on adding this image i get these two new values in my post array?!

    [edit_x] => 26
    [edit_y] => 2

    wtf?!

  4. #4
    Join Date
    Sep 2006
    Location
    Copenhagen, Denmark
    Posts
    1,253
    i.e. just to spoof the underline rollover of text?
    I don't understand what you mean.

  5. #5
    Join Date
    Mar 2005
    Location
    planet earth
    Posts
    121
    Quote Originally Posted by Dok
    I don't understand what you mean.
    you know, the underline onmouseover hover of a text link...?

    i've made small gif's out of the text, so it looks like a text link..

    it's not important, just wondering if there was a way of doing it..

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