Hello people
i created this code:
<script langauge=javascript>
function baby(a,b)
{
document.p.text=a;
document.p.cat.checked=true;
}
</script>

<form name="p" >
<input type="checkbox" name="cat[10]">
<input type="checkbox" name="cat[11]">
<input type="text" name="text">
</form>

<a href="javascript:baby('Hello',10);">Click Here</a>


when i click on The "Click Here" the textbox show me Hello but the checkbox doesn't work and dosen't get check.

Now How can i do? how can i check of the checkboxes?


Another question:
you assume that i have some checkboxes with the diffrent name such as
<input type="checkbox" name="cat[110]">
<input type="checkbox" name="cat[101]">
<input type="checkbox" name="cat[011]">
.
.
.

now how can i uncheck them at a moment?

Hi,

try this

<html>
<head>
<script langauge=javascript>
function baby(a,b)
{

document.p.text.value=a;
document.getElementById(b).checked=1; 
}
</script>
</head>
<body>

<form name="p" >
<input type="checkbox" name="cat(10)" id=10 >
<input type="checkbox" name="cat(11)" id=11 >
<input type="text" name="text">
</form>

<a href="javascript:baby('Hello',11);">Click Here</a>
</body>
</html>

Thanks a lot kb.net , Thank you very much ,
dear now how can i unchecked al of them with diffrent id or name at a moment? for example:

<input type="checkbox" name="cat(5)" id=5>
<input type="checkbox" name="cat(9)" id=9>
<input type="checkbox" name="cat(20)" id=20 >
<input type="checkbox" name="cat(11)" id=11 >

and how can i hide them?

no one can help me? i want to do this

how can i unchecked al of them with diffrent id or name at a moment? for example:
<input type="checkbox" name="cat(5)" id=5>
<input type="checkbox" name="cat(9)" id=9>
<input type="checkbox" name="cat(20)" id=20 >
<input type="checkbox" name="cat(11)" id=11 >

Hi,

Amend your code to look something like this

<html>
<head>
<script langauge=javascript>
function baby()
{
for (var x= 1; x<=4 ;x++)
document.getElementById(x).checked=0; 
}
</script>
</head>
<body>

<form name="p" >
<input type="checkbox" name="cat(5)" id=1 >
<input type="checkbox" name="cat(9)" id=2 >
<input type="checkbox" name="cat(10)" id=3 >
<input type="checkbox" name="cat(12)" id=4 >
</form>

<a href="javascript:baby();">Click Here</a>
</body>
</html>
This article has been dead for over six months. Start a new discussion instead.