Jump to content

Dialogue box in PHP - How?


ibexy

Recommended Posts

I have the following which generates a dialogue box from php with an [ok] and a [cancel] button.  Its working but I cant figure out how to transfer the value of (x) to php so I can stop or go on with the action.

echo("<script type='text/javascript'>var x=window.confirm('Would you like to continue?') </script>");

 

I have tried to test for (x) like this but its not working:

 

if (x) {
	blah blah blah

 

What am I doing wrong here?

 

Link to comment
https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/
Share on other sites

Yes, like I said, its working fine from javascript. The box is displaying fine but the rest of the program is in php. How can I make php test for the variable (x) which is getting its value from the javascript.

 

echo("<script type='text/javascript'>var x=window.confirm('Would you like to continue?') </script>");

 

Below is a break down of what I want to do:

 

if (x) = ok
   carry out the action
} else {
   abort
}

 

php does not seem to recognise (x). Is that because its getting its value from within a javascript code?  or probably, am getting it all wrong. Someone help a newbie!

The only way you can pass information from Javascript to PHP is to use AJAX techniques.

 

PHP and Javascript run at two different contexts. PHP runs on the server and when it's all done, the browser see the output and if there is any Javascript it is executed.

 

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.