Page 1 of 1
HOW: get the value of confirm message box with PHP?
Posted: Wed Feb 21, 2007 8:16 pm
by victhour
hello guys,
could anyone show me how to the value of confirm box with ("or pass the value to") PHP?
ex: confirm("Are you sure you want...")
hope anyone would reply to this...
many tanx again in advanced...
Posted: Wed Feb 21, 2007 9:29 pm
by volka
confirm() is a client-side function, it runs "in" the browser. php is (mainly) a server-side language, it's not aware of what the client does client-side.
Please explain in more detail what you're trying to achieve.
Posted: Wed Feb 21, 2007 10:43 pm
by Kieran Huggins
by the way, it either returns TRUE or FALSE in javascript. Use something like:
Code: Select all
if(confirm('are you sure????')) // do something
Returning FALSE during the onclick event of an Anchor (<a>) element will cancel the navigation...that's how I use it most often.
Posted: Thu Feb 22, 2007 3:36 am
by CoderGoblin
If asking for deletion, I tend to create a hidden input field in the form with a value of 1 e.g <input type='text' name='del_conf' value=1 /> when the user confirm the deletion (using javascript). Only when my PHP form processing finds this value does it delete anything. Catering for those people who do not use javascript is another problem,
Posted: Thu Feb 22, 2007 10:04 am
by Kieran Huggins
I just attach a "confirm" to the link s above, so no javascript = no extra warning, but the functionality survives.
Posted: Thu Feb 22, 2007 2:15 pm
by visitor-Q