|
Im having a bit of trouble getting information from php into javscript. I know php is server side and js is browser but im sure this can work as all my variables are set on page load. The problem is variables codeofheight and codeofwidth in my js function - it works if i replace codeofwidth and codeofheight variables with appropriate values, but not otherwise. Can someone show me how this can work please.
[js]
<script>
var codeofheight = doorglass.codeofheight.value;
var codeofwidth = doorglass.codeofwidth.value;
if(document.images)
{
bar = new Array()
for(i=0;i<3;i++)
{
bar[i] = new Image()
bar[i].src = "images/"+codeofwidth+"_"+codeofheight+"_bar" + i + ".gif"
} }
function barsauto1()
{ if(document.images) { choose=document.doorglass.door1bars.options[document.doorglass.door1bars.selectedIndex].text.charAt(0)
document.barswitch1.src = "images/"+codeofwidth+"_"+codeofheight+"_bar"+choose+".gif " } }
window.onerror = null;
</script>
<?php
$codeofheight='1600'; //in the real script these variables are set by a series of if statements, determined by info from previous page.
$codeofwidth='2ds';
echo"
<form name='doorglass' action='somewhereelse.php'>
<input type='hidden' name='codeofheight' value='$codeofheight'>
<input type='hidden' name='codeofwidth' value='$codeofwidth'>
</form>
";?>
[/js]
|