Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Firefox Ignores My Confirm Box but IE OK

halibutfishfinder2 (TechnicalUser) (OP)
30 Nov 07 8:00
Firefox Ignores My Confirm Box but IE OK.

Can anyone see where I am going wrong? My script is supposed to check for checked boxes, then request a confirmation before posting the form. I could probably fix this by not using the submit button but I need this to submit without Javascript if it's disabled.

Strange thing is it seems fine in IE7 but not in Firefox as it posts the form while the confirm box is up.

Thanks.

/*Informs the user if no check boxes are checked and asks confirmation before posting the form*/
function confirmdelete(formname,nothingmessage,confirmmessage)
{
    //Count selected checkboxes
    var formControls = document.formdelete.elements;
    var c = 0;
    for (var i = 0; i < formControls.length; i++)
    if (formControls[i].type.toLowerCase() == 'checkbox'
    && formControls[i].checked)
    c++;
    //If no checkbox is selected
    if (c==0)
    {
    alert(nothingmessage);
    return false;
    } else {
    // entry is marked so show confirm option    
    var agree=confirm(confirmmessage);
    if (agree)
    {
    //Submit the form
    //return true;
    document.forms[formname].submit();
    }
    else
    return false;
    }
}

And the function call...
<input name="delete" id="delete" type="submit" value="Yes" onmousedown="return confirmdelete('formdelete','You must mark an entry first','Are you sure you want to delete marked entries?')" />
nickdel (Programmer)
30 Nov 07 8:44
try this...

CODE

<input name="delete" id="delete" type="submit" value="Yes" onclick="return confirmdelete('formdelete','You must mark an entry first','Are you sure you want to delete marked entries?'); return false;" />

Cheers

nick
halibutfishfinder2 (TechnicalUser) (OP)
30 Nov 07 9:13
Many thanks nick,

it now works fine in both browsers and is unobtrusive - just how I like it.

Regards

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close