Hi
How to pass javascript variable in PHP?
Any help ?
<snip>
Hi
How to pass javascript variable in PHP?
Any help ?
<snip>
Yes sure, give us an example of what you want to send.
One way is to:
<script type="text/javascript" charset="utf-8">
var myJsVar="<?php echo $myPhpVar; ?>";
</script>
Here’s an onclick example:
echo '<input id="server" onclick="window.location.href=\\'filename.php?server='.$server.'\\'" type="button" name="server" value="Server">';
That’s javascript using a php variable - don’t think it can be done the other way round.
I am understanding your problem but there is no way to pass the javascript variable to php page rather than ajax or window.location method.
<script type="text/javascript">
function passvariable(var){
window.location.href= 'filename.php?var='+var;
}
</script>
<input type="button" value="submit" onclick="passvariable('<?php echo $phpvariable;?>');"/>