Jump to content

Simple Confirm pop-up


jaminxz

Recommended Posts

Hi guys,

 

i have some rows, each with a checkbox on a php webpage. When the 'submit' button is clicked, each row with a checked checkbox has its status field updated. This all works fine but now i have tried to put a simple javascript pop-up box in to ask the user if he/she is sure she wants to update the selected recrod(s). My problem is that if whatever the user selects (ok or cancel) the post still happens and the fields are updated. I'd really appreciated it if someone could look over a newbie's code and point me in the right direction!thanks in advance,

Jaminxz.

 

<!----------------in the head

 

<script language="javascript1.2">

 

var form_id;

function confirm_delete(go_url)

{

var answer = confirm("Are you sure to delete the  selected row?");

if (answer)

{

location=go_url;

}

}

</script>

 

 

<!---------------the form

 

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" id="Updated_Rows_Form">

 

 

<!-----------the button

 

<input type="submit" name="Confirm" value="Close Selected" onClick="confirm_delete('<?php echo $_SERVER['PHP_SELF'];?>')" />

 

Link to comment
Share on other sites

get rid of the onclick in the submit button, and change your form tag to:

 

<form action="" method="post" id="Updated_Rows_Form" onsubmit="return confirm('Are you sure to delete the selected row(s)?');"> 

...i also removed the action, since it will default to itself if it's empty

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.