Link to home
Start Free TrialLog in
Avatar of nikola_mk
nikola_mk

asked on

php yes no message box

Hi

Can some one tell me how to display yes no message box in php coded  like code below

message box can be javascript

Thanks
if(isset($_GET["action"])) {
		  switch ($_GET["action"]) {
			case "del":

		//here message box "are you want to delete?" and if user click "yes" echo"Delete" if click "no" echo "No Delete"	    

			break;
			
			case "edit":
				
//here same message box for edit 

			break;
		}

Open in new window

Avatar of jfromanski
jfromanski
Flag of Poland image

Use JavaScript and the method confim(message) on your first page, before calling your php. Eg.
if (confirm(message)){
  submit_request;
} else {
  do_nothing;
}
Avatar of hielo
>>if(isset($_GET["action"]))
Somewhere else you probably have a link or a button. It is THERE that you need to do this, NOT on the php code you are pointing out:

<a href='#' onclick='retrun confirm("Are you sure you want to delete this item?") '>Delete</a>
In VBScript ( which will only work in Explorer ) you can try this:
<script language="VBScript">
Dim intAnswer
intAnswer = MsgBox("do you want only YES and NO?", vbYesNoCancel)

If intAnswer = 6 Then
   ' Yes.
ElseIf intanswer = 7 Then
   ' No
Else
   ' Cancel
End If
</script>

Else, you can try to create a modal javascript box to encompass this.
Avatar of nikola_mk
nikola_mk

ASKER

I use this code but message box did not  appear

            <td> <a  href='?action=del' onCLick='return confirm('Are you SURE you want to delete this record?')'> <img alt='del' src='delete_cell.jpg' title='del'  /> </a>

where I'm wrong?

thanks
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial