send javaScript variable to php variable -
possible duplicate:
how pass javascript variables php?
first thought had convert javascript php, found out cannot because of server , client side executions. want send 1 variable
<script type="text/javascript"> function scriptvariable() { var thecontents = "the variable"; } </script>
to php variable
<?php $phpvariable ?>
that function in javascript executes when let's click on button.
now have no idea on how assign phpvariable javascript 1 use phpvariable stuff in database. know can add url or thing , refresh page.. ajax might have use ajax method further in webpage...
so there easy way without having dump pages of code on page 1 simple thing?
as jordan said have post javascript variable server before server can handle value. can either program javascript function submits form - or can use ajax / jquery. jquery.post
maybe easiest approach this
function myjavascriptfunction() { var javascriptvariable = "john"; window.location.href = "myphpfile.php?name=" + javascriptvariable; }
on myphpfile.php can use $_get['name']
after javascript executed.
regards
Comments
Post a Comment