greens85 Posted March 6, 2011 Share Posted March 6, 2011 Hi all, I have a variable declared in my document like so: $product->greeting = "Some Text"; This text can be edited by clicking on a button which calls some javascript: <?php session_start() ?> <script type="text/javascript"> function changeText2(){ var userInput = document.getElementById('userInput').value; window.opener.document.getElementById('element-greeting-content').innerHTML = userInput; window.close('editText.php'); } </script> <textarea name="userInput" id="userInput" cols="32" rows="10"><?php echo $_SESSION['greeting']; ?></textarea> <input type='button' onclick='changeText2()' value='Update Text'/> The javascript updates the div that the php variable is sitting in, so to the naked eye it looks like the variable has been updated. However when proceeding to the next page I get the old value rather than the new one. I think the reason for this is that the div is just getting a new value rather than the variable being updated. Does anyone have any ideas on how the the variable can be updated, so that when proceeding to the next page the new value is shown instead of the old value? many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/229789-updating-a-php-variable/ 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.