mariosuyoto Posted April 6, 2009 Share Posted April 6, 2009 I have an example code like this : <script language=javascript> function edit() { <? $status="edit";?> { function new() { <? $status="new";?> { </script> <form method=post action=storage.php> <input type=button name=edit value=EDIT onClick=edit()> </form> The problem is i can't get $status at storage.php as i want ($status = new) Any help for my problem? and how should i do to get $status = "edit" at storage.php? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/152764-changing-php-variable-from-javascript/ Share on other sites More sharing options...
Mchl Posted April 6, 2009 Share Posted April 6, 2009 PHP is executed on server. Then the output is sent to browser, where JavaScript is executed. Browser does not see PHP, and cannot change any PHP variables. In short: what you trying is impossible. Quote Link to comment https://forums.phpfreaks.com/topic/152764-changing-php-variable-from-javascript/#findComment-802184 Share on other sites More sharing options...
Daniel0 Posted April 6, 2009 Share Posted April 6, 2009 You could store it in a cookie, use AJAX, or just do a regular GET/POST request to "transfer" it to PHP though. Quote Link to comment https://forums.phpfreaks.com/topic/152764-changing-php-variable-from-javascript/#findComment-802214 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.