|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Simple yes/no terminate
My apologies, this is a very elementary question. I have a 'delete' and 'edit' link on my page which work. They post the type and id to a new page and subsequently either delete the record or have a form which the record can be edited in.
BEFORE posting to the page, I would like to add a message box question, "Are you sure you want to delete $id?". If the person answers YES, it posts to the next page. If they answer NO, it exits. Sort of like in PHPMyAdmin when you click DELETE on a record. Thanks, Doug |
|
#2
|
|||
|
|||
|
RE: Simple yes/no terminate
You want the confirm() function. Here it is in a usable form:
Code:
function confirmit(){
if(confirm('Are you sure?')){
return true;
}else{
return false;
}
}
Then on your submit button, add: Code:
onclick="return confirmit();" |
|
#3
|
|||
|
|||
|
RE: Simple yes/no terminate
brut's first javascript function was right. But I doubt whether it will work if you place onClick command on submit button.
I call it on <form> onSubmit event. ex: Code:
<form name="frm" method="post" action="process.php" onSubmit="return confirmit();"> |
|
#4
|
|||
|
|||
|
RE: Simple yes/no terminate
The onClick event can be called from EITHER the form tag OR the Submit button!!! but the poster seems to be using links and wants the id displayed as well, so the confirm would need to be called from the link like so.
<a href="delete.php?id=<? echo $id_to_delete;?>" onClick="return confirm('Are your sure you want to delete ' + <? echo $id_to_delete;?> + '?')">delete</a> |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Simple yes/no terminate |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|