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
https://forums.phpfreaks.com/topic/146517-simple-confirm-pop-up/
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.