gencoglu
03-29-2010, 09:39 PM
Hi,
I have the following javascript codes.
I have two textboxes with id "pano" and "pano2"
My function creates numbers randomly and that if random number==1 let the background of textbox2 be pink and if random number==2
textbox1 be red. The code works fine for document.bgColor but it does not work for textboxes
how can I modify the code so that I can change the background color of any textboxes ?
thanks..
<script>
aaa=setInterval("letsgo()",500);
function letsgo()
{
rno=Math.floor(Math.random()*3)+1;
document.getElementById("counter").value=rno;
if(rno==3)
{
document.bgColor="green";
}
if(rno==2)
{
var pano=document.getElementById("pano");
document.pano.bgColor="red";
}
if(rno==1)
{
var pano2=document.getElementById("pano2");
document.pano2.bgColor="pink";
}
}
</script>
<input type="text" id="counter" style="position:absolute;top:10px;left:50px;width:60px;height:20px;">
<input type="text" id="pano" style="position:absolute;top:100px;left:100px;width:200px;height:200px;">
<input type="text" id="pano2" style="position:absolute;top:100px;left:400px;width:200px;height:200px;">
I have the following javascript codes.
I have two textboxes with id "pano" and "pano2"
My function creates numbers randomly and that if random number==1 let the background of textbox2 be pink and if random number==2
textbox1 be red. The code works fine for document.bgColor but it does not work for textboxes
how can I modify the code so that I can change the background color of any textboxes ?
thanks..
<script>
aaa=setInterval("letsgo()",500);
function letsgo()
{
rno=Math.floor(Math.random()*3)+1;
document.getElementById("counter").value=rno;
if(rno==3)
{
document.bgColor="green";
}
if(rno==2)
{
var pano=document.getElementById("pano");
document.pano.bgColor="red";
}
if(rno==1)
{
var pano2=document.getElementById("pano2");
document.pano2.bgColor="pink";
}
}
</script>
<input type="text" id="counter" style="position:absolute;top:10px;left:50px;width:60px;height:20px;">
<input type="text" id="pano" style="position:absolute;top:100px;left:100px;width:200px;height:200px;">
<input type="text" id="pano2" style="position:absolute;top:100px;left:400px;width:200px;height:200px;">