Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirm Box with Javascript and PHP 1

Status
Not open for further replies.

patrickstrijdonck

Programmer
Jan 18, 2009
97
0
0
NL
Hi all,

In PHP section i asked how i can create a confirmbox before it will submit the form,

Here what i have now:

Code:
?>
<SCRIPT LANGUAGE="Javascript">
<!--                    
function checkAction(myMessage)            {    result=confirm(myMessage);               
if (result==true) { return true; } 
else 
{ return false; }            
}            
//-->
</SCRIPT>

and as button i have:
Code:
<input class="form_button" name="DEL" type="submit" value="Personeelslid Verwijderen" onClick="return checkAction(\'Weet u zeker dat u deze personeelslid wilt verwijderen?\')" />

When i press the button, it should go to the function, but instead, it justs submits the form.... without asking the question to confirm the delete....

Doing something wrong??
 
Remove the backslashes before single qoutes

Code:
<input class="form_button" name="DEL" type="submit" value="Personeelslid Verwijderen" onClick="return checkAction('Weet u zeker dat u deze personeelslid wilt verwijderen?')" />

Cheers,
Dian
 
However, I'd say the correct place for code of this sort is still within the 'onsubmit' attribute of the form, as forms can be submitted on more ways than simply clicking a button - which your code will not trap.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Well, maybe you can show differente messages depending on how the form is submitted.

Cheers,
Dian
 
Ty for the tip, i use Onsubmit on other pages, but for this one, the Delete button is the only way to delete the record.... so its no big deal....


Ty anyway :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top