ibexy Posted February 15, 2008 Share Posted February 15, 2008 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 More sharing options...
priti Posted February 15, 2008 Share Posted February 15, 2008 Hi, Those events can be handled with javascript??? Then handle the functions from there. Regards Link to comment https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-467579 Share on other sites More sharing options...
ibexy Posted February 15, 2008 Author Share Posted February 15, 2008 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 https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-467608 Share on other sites More sharing options...
nikefido Posted February 15, 2008 Share Posted February 15, 2008 you can't pass values from php to javascript and visa-versa that easily. (altho it would be nice). be aware that you shouldn't rely on javascript as users can shut it off in their browsers. Link to comment https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-467628 Share on other sites More sharing options...
ibexy Posted February 15, 2008 Author Share Posted February 15, 2008 thanks for that infor. Is there no other way to create an [Ok] [Cancel] dialogue box in php? Link to comment https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-467640 Share on other sites More sharing options...
kenrbnsn Posted February 15, 2008 Share Posted February 15, 2008 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 https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-467644 Share on other sites More sharing options...
priti Posted February 18, 2008 Share Posted February 18, 2008 thanks for that infor. Is there no other way to create an [Ok] [Cancel] dialogue box in php? Hi, Well i have done it but thru AJAX . So it made my life easier :-) Link to comment https://forums.phpfreaks.com/topic/91232-dialogue-box-in-php-how/#findComment-469319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.