|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
confirm box
hello. pl help with the follwing;
I want to make a confirm box. If someone clicks OK, the form is submitted, if clickes Cancel nothing happends. This is what I have so far: Code:
<script language="JavaScript">
<!--
function confirm_entry()
{
var agree=confirm("OK to Continue r Cancel to stop the execution");
if (agree)
{
// when ok is pressed the form is submitted
}
else
{
// when cancel is pressed nothing happends
}
}
-->
</script>
<form name="" action="test.php" method="post" onSubmit="confirm_entry();">
<input type="submit">
</form>
in this situation, if I click ok, the form is submitted, but the same thing is happening if i click cancel |
|
#2
|
|||
|
|||
|
RE: confirm box
You need to return the value of the selection to the function call in order for it to work properly.
<script language="JavaScript"> <!-- function confirm_entry() { var agree=confirm("OK to Continue r Cancel to stop the execution"); if (agree){ // when ok is pressed the form is submitted return true; }else{ // when cancel is pressed nothing happens return false; } } --> </script> <form name="" action="test.php" method="post" onSubmit="return confirm_entry();"> <input type="submit"> </form> |
|
#3
|
|||
|
|||
|
RE: confirm box
thx. works great
|
|
#4
|
|||
|
|||
|
RE: confirm box
Here is a small function that I use:
Code:
function confirmForm(the_form, the_message) {
// No confirmation for opera and empty message
if (the_message == '' || typeof(window.opera) != 'undefined') {
return true;
}
// Let me ask you someting...
var confirmed = confirm(the_message);
// Add confirmed stamp
if(confirmed) {
the_form.action += '&confirmed=1';
}
// And return
return confirmed;
}
And in form: Code:
<form action="?process=1" onsubmit="return confirmForm(this, 'Question...');"> .... </form> This is small modification of confirm link function form phpMyAdmin JS... I find it very useful. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > confirm box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|