Jump to content

[SOLVED] How to include yes/no dialog box


marukochan

Recommended Posts

Hi!

 

How can I have a dialog box to confirm with the user whether he really wants to delete a specific record.

 

My code:

Here is where the user click the 'thrash' icon to delete a record.

.....

echo("<td width=15% align=middle><a href='admin_delete.php?id=".$row["project_id"]."'><img src='images/icon_delete.gif' border='0'></a>");

.....

So, before deleting the record I want to have a dialog box to confirm whether he wants to proceed with the deleting or not.

 

How can I do that ?

 

TQ

Link to comment
Share on other sites

How can I have a dialog box to confirm with the user whether he really wants to delete a specific record.

 

A true dialog box cannot be spawned from pure PHP.  It's a client-side action, so you need to use Javascript.  You could add an onclick attribute to the anchor tag for the delete link.  Something like this:

 

<a onclick="return confirm('Are you sure you want to delete this record?);" href="admin_delete.php?id=[...]

 

Please note that single-quoting attribute values is not XHTML-compliant.

Link to comment
Share on other sites

Ferguser,

 

If I try to write this way within html, it is working

....

<td width=15% align=middle><a href="admin_delete.php?id="<? echo $row["project_id"]; ?>"" onClick="javascript:return confirm('Are you sure you want to delete this record?')"><img src='images/icon_delete.gif' border='0'></a>");

...

 

but when I wrote it this way within php, it is not working. I am so confused. How and when should I use single or double quoting. Can you correct my single and double quoting in this code?

 

....

echo("<td width=15% align=middle><a href='admin_delete.php?id=".$row["project_id"]."' onClick='javascript:return confirm('Are you sure you want to delete this record?')'><img src='images/icon_delete.gif' border='0'>[/a]");

....

Link to comment
Share on other sites

 

....

echo '<td width=15% align=middle>';

echo '<a href="admin_delete.php?id='. $row["project_id"] .'" ';

echo 'onClick="javascript:return confirm(\'Are you sure you want to delete this record?\')">';

echo '<img src="images/icon_delete.gif" border="0">';

....

 

 

monk.e.boy

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.