Page 1 of 1

linking PINK variable to html variable

Posted: Mon Apr 08, 2013 9:20 am
by JohnnyCanuck
Hi All,
I am trying to update the PINK's webpage using javascript.
I have tried all sorts of different ways to assign the value of Nb_var01 to my external variable (client-side variable?).
I'm an absolute noob so please be patient. Thanks


Here is my script (see line 4 in particular):

<p id="demo"></p>

<script>

var x="";

var time='<%=Nb_var01%>';

if (time==1)
{
x="Light is ON";
}
else if (time==0)
{
x="Light is OFF";
}

document.getElementById("demo").innerHTML=x;

</script>

Re: linking PINK variable to html variable

Posted: Mon Apr 08, 2013 11:21 am
by JohnnyCanuck
Hi All,
I finally figured it out (admittedly, with some searching around the internet).

The webpage is comprised of just two buttons (On and Off) and a graphic of a light bulb.
When the user presses the On button the graphic correspondingly changes to show a lit bulb.
When the user presses the Off button the graphic correspondingly changes to show an ulit bulb. Very basic indeed.

The On and Off buttons change the value assigned to Nb_var01 from 0 to 1.
The images are tied to the Nb_var01 variable.

Here's the code:

<html>
<body>

<body bgcolor ="blue" text="white">
<form method="post"
<p>
<input name="Nb_var01" type="hidden" value="1">
<input type="submit" value="ON">
</form>
</p>

<form method="post"
<p>
<input name="Nb_var01" type="hidden" value="0">
<input type="submit" value="OFF">
</form>
</p>


<script type="text/javascript">
var name = "<Nb_var01>"
if (name == 1)
{
document.write('<img src="light_on_A.gif">')
}
else
{
document.write('<img src="light_off_A.gif">')
}
</script>
</body>
</html>