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
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!

Link to comment
Share on other sites

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

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.