Why doesn't this code work????
rD is the # of red buttons "on",Code:<head> <script language="javascript" type="text/javascript"> var rD = 2; var gN = 2; var bL = 2; var iD_is;
gN is the # of green buttons "on",
bL is the # of blue buttons "on", &
iD_is is the id of the img to change.
It is supposed be just 2 different lines of changing buttons. I was planning to use the "+" and "-" buttons to add/subtract button lights from a column. Unless I did something wrong, I think it should work, but it doesn't... Why?Code:</script> <script language="javascript" type="text/javascript"> function red_down() {if (rD != 0);{rD-=1}; if (rD = 0);{iD_is = 'r1'}; if (rD = 1);{iD_is = 'r2'}; {document.getElementById(iD_is).src = 'http://bit.ly/red_xed'};} </script> <script language="javascript" type="text/javascript"> function green_down() {if (gN != 0);{bL-=1}; if (gN = 0);{iD_is = 'g1'}; if (gN = 1);{iD_is = 'g2'}; {document.getElementById(iD_is).src = 'http://bit.ly/green_xed'};} </script> <script language="javascript" type="text/javascript"> function blue_down() {if (bL != 0);{bL-=1}; if (bL = 0);{iD_is = 'b1'}; if (bL = 1);{iD_is = 'b2'}; {document.getElementById(iD_is).src = 'http://bit.ly/blue-xed'};} </script> <script language="javascript" type="text/javascript"> function red_up() {if (rD != 2);{rD+=1}; if (rD = 2);{iD_is = 'r2'}; if (rD = 1);{iD_is = 'r1'}; {document.getElementById(iD_is).src = 'http://bit.ly/red_button'};} </script> <script language="javascript" type="text/javascript"> function green_up() {if (gN != 2);{gN+=1}; if (gN = 2);{iD_is = 'g2'}; if (gN = 1);{iD_is = 'g1'}; {document.getElementById(iD_is).src = 'http://bit.ly/green_button'};} </script> <script language="javascript" type="text/javascript"> function blue_up() {if (bL != 2);{bL+=1}; if (bL = 2);{iD_is = 'b2'}; if (bL = 1);{iD_is = 'b1'}; {document.getElementById(iD_is).src = 'http://bit.ly/blue-button'};} </script> </head> <body> <table> <tr> <td><button onclick="red_down()">-</button></td> <td><button onclick="green_down()">-</button></td> <td><button onclick="blue_down()">-</button></td> </tr> <tr> <td><img id="r1" src="http://bit.ly/red_button"></td> <td><img id="g1" src="http://bit.ly/green_button"></td> <td><img id="b1" src="http://bit.ly/blue-button"></td> </tr> <tr> <td><img id="r2" src="http://bit.ly/red_button"></td> <td><img id="g2" src="http://bit.ly/green_button"></td> <td><img id="b2" src="http://bit.ly/blue-button"></td> </tr> <tr> <td><button onclick="red_up()">+</button></td> <td><button onclick="green_up()">+</button></td> <td><button onclick="blue_up()">+</button></td> </tr> </table> </body>


Reply With Quote
Bookmarks