Javascript variables are not working
Posted
by linkcool
on Stack Overflow
See other posts from Stack Overflow
or by linkcool
Published on 2010-05-20T03:20:27Z
Indexed on
2010/05/20
3:30 UTC
Read the original article
Hit count: 145
Hi, my problem is that my variables are not working in javascript. all variables need names without some character at the beginning, this is the stupid thing...Anyways, im trying to make a funtion that makes "select all checkboxes". It is not working so i looked at the page source/info and found out that the variables were not changing.
this is my input:
echo "<input onclick='checkAll(1);' type='checkbox' name='master'/><br/>";
My function:
function checkAll(i)
{
for(var i=1; i < <?php echo $num; ?>; i++)
{
if(document.demo.master[i].checked == true)
{
document.demo.message[i].checked = true;
}
else
{
document.demo.message[i].checked = false;
}
}
}
so yes that's it. I can tell you that i also tried without the <i>
in: checkAll("i")
Thanks for the help.
© Stack Overflow or respective owner