Hi Every one.
I finally figured a way to pass JavaScript variables to PHP.
I takes 3 files.
1. Setup file a PHP or HTML
<script language="javascript">
var1= 9;
var2= 19;
var3= 'time';
</script>
<!-- now we are calling the sender script -->
<script language="javascript" src="sendpar.js"></script>
2. the "translation" file is a JavaScript FORM
document.write('<form name="sendme" action="showpar.php" method="post"><input type="hidden" name="par1" ><input type="hidden" name="par2" ><input type="hidden" name="par3" >');
sendme.par1.value = var1;
sendme.par2.value = var2;
sendme.par3.value = var3;
document.write('</form>');
document.sendme.submit() ;
3. is the PHP "receiver file"
just a simple file to show you all values:
<?php
foreach($_POST as $key => $dat) {
echo $key .'='. $dat ."\r\n";
}
?>
That is ALL.
Good Luck!



Reply With Quote

Bookmarks