Jump to content

Updating a php variable?


greens85

Recommended Posts

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.

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.