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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.