Page 1 of 1
Dont think my syntax is right message box not appearing.
Posted: Thu Jul 05, 2007 10:59 am
by Beebosoft
I have a page where the sure can cancel a booking and want a message bot to appear to check they really want to do this. I put sone code in which works is just in html but isn't bringing up a message box .
The code I am using is as follows
Code: Select all
print "<a href ='delete.php?id=$bookingid' onclick='if (confirm('Are you sure you want to cancel this booking? or \nCancel if you do not want to. ')){return true}else{return false}'>Cancel</a>";
Any help would be appreciated.
Nuts
Posted: Thu Jul 05, 2007 11:04 am
by superdezign
Escape the quotes. This is what you are actually outputting (note the highlighting):
Code: Select all
<a href ='delete.php?id=$bookingid' onclick='if (confirm('Are you sure you want to cancel this booking? or \nCancel if you do not want to. ')){return true}else{return false}'>Cancel</a>
Posted: Thu Jul 05, 2007 11:16 am
by Beebosoft
I am sorry I am being really thick today. I am not sure what you mean by escape the quotes.
Posted: Thu Jul 05, 2007 12:05 pm
by superdezign
You can't have single quotes nested in single quotes. You can't have double quotes nested in double quotes. You have to escape the others.
Code: Select all
echo 'This is how you \'escape quotes\'.';
Posted: Fri Jul 06, 2007 4:43 am
by Beebosoft
I have put the escape quotes in now thank you for that info but it is still not bringing up a message. I have included the whole line
Code: Select all
print "<tr><td>$courseid</td><td>$name</td><td>$email</td><td>$phone</td><td>$add</td><td>$postcode</td><td>$company</td><td>$datebooked</td><td><p><a href ='delete.php?id=$bookingid' onclick='if (confirm(\'Are you sure you want to cancel this booking? or Cancel if you do not want to. \')){return true}else{return false}'>Cancel</a></p></tr>";
Any help appreciated
Posted: Fri Jul 06, 2007 5:12 am
by Gente
Code: Select all
print "<tr><td>$courseid</td><td>$name</td><td>$email</td><td>$phone</td><td>$add</td><td>$postcode</td><td>$company</td><td>$datebooked</td><td><p><a href ='delete.php?id=$bookingid' onclick=\"if (confirm('Are you sure you want to cancel this booking? or Cancel if you do not want to. ')){return true}else{return false}\">Cancel</a></p></tr>";