PDA

View Full Version : Refresh page, W/O sending form data


WebAsh
02-23-2004, 04:55 AM
I have a form, and a submit button on that form that pops up a confirm window and if the user hits OK it goes through fine, BUT if the user clicks CANCEL i want the page to either refresh without sending the POST data in the form or go back to the page, without refreshing OR sending the data... HELP!!!!

agent002
02-23-2004, 08:03 AM
Hi AHHQ_Man, nice to see you here too. Could you please show us the code you have, so we can implement the function to it?

WebAsh
02-23-2004, 05:44 PM
yea, i never thought i would turn to the javascript side! but unfortunately i have to!

But i currently dont have a the script with me, ill get home later tonight and post it

but it goes sumthing like this:
<script language="javascript">
function rusure() {
var sure=confirm("Are you sure you wish to delete this file?")
if (!sure) {
//Here is where i want the "cancel form data sending" thing
}
}
</script>

Yea.... and i call it like this:
<form action="editor.php" method="post">
...
<input name="delete_filename" type="text" onclick="rusure()">
...
</form>

Do u need anything else?

agent002
02-24-2004, 04:51 AM
Instead of calling it on the buttons onclick action, call it for the form's onsubmit action. Then, modify your code a bit:
<script type="text/javascript">
function rusure(){
return confirm("Are you sure you wish to delete this file?");
}
</script>

...

<form action="editor.php" method="post" onsubmit="return rusure();">
<input name="delete_filename" type="text">
</form>

WebAsh
02-26-2004, 08:52 PM
Cheers, :D