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
https://forums.phpfreaks.com/topic/229789-updating-a-php-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.