|
-
Jul 27th, 2005, 04:20 AM
#1
Thread Starter
Addicted Member
Store in php variable onclick()
Hey, i have a textbox and an image.... When the image is clicked, i need all the text in the textbox to be stored in a PHP session variable.
Is this possible?
i was going to do womething like this:
Code:
<script>
function assignvariable() {
var currentvalue = document.form1.message.value;
document.write("<?php $_SESSION['message'] = " + currentvalue);
}
</script>
Would someone mind telling me if this is the way to go about it??
Many thanks, BIOSTALL
-
Jul 27th, 2005, 05:27 AM
#2
New Member
Re: Store in php variable onclick()
Your onclick event is a client-side event. To set a session variable you'll need to go via the server reload the page.
Code:
<script>
function assignvariable() {
var currentvalue = document.form1.message.value;
window.href="the_same_page.php?message="+document.form1.message.value;
}
</script>
<?php $_SESSION['message'] = $_GET["message"]; ?>
hope this helps
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|