I m trying to make select all function in my html page thru javascript

<HTML>
<HEAD>

</HEAD>
<BODY>
<% Id = 0
Idd = 10%>
<form name ="frm1" ><input type=checkbox value=1 name =selall onClick="checkall();">
<input type=hidden name=Id value=" <%= Id %>" >
<input type=hidden name=Idd value=" <%= Idd %>" >
</form>
<form name =frm2 >

<% For i =1 to 10 %>

<input type=checkbox name ="sel<%= i %>" value = 1>

<% Next %>
</form>


</BODY>
</HTML>
<script language="javascript">

function checkall()
{

var i = frm1.elements(1).value;
var j =0;
var k = frm1.elements(2).value;

if(document.frm1.selall.checked == true)
{

// alert(k);
for(j=i;j<k;j++)
{
document.frm2.elements(j).checked = true;
}
}
else
{
for(j=i;j<k;j++)
{
document.frm2.elements(j).checked = false;
}
}
}
</script>

the
above code is giving error:document.frm2.elements(j).checked
is not an object

although if i use 0 and 10 instead of i and k resp in for loops it work fine i.e.

<HTML>
<HEAD>

</HEAD>
<BODY>
<% Id = 0
Idd = 10%>
<form name ="frm1" ><input type=checkbox value=1 name =selall onClick="checkall();">
<input type=hidden name=Id value=" <%= Id %>" >
<input type=hidden name=Idd value=" <%= Idd %>" >
</form>
<form name =frm2 >

<% For i =1 to 10 %>

<input type=checkbox name ="sel<%= i %>" value = 1>

<% Next %>
</form>


</BODY>
</HTML>
<script language="javascript">

function checkall()
{

//var i = frm1.elements(1).value;
var j =0;
// var k = frm1.elements(2).value;

if(document.frm1.selall.checked == true)
{

// alert(k);
for(j=0;j<10;j++)
{
document.frm2.elements(j).checked = true;
}
}
else
{
for(j=0;j<10;j++)
{
document.frm2.elements(j).checked = false;
}
}
}
</script>

tell me how to convert the hidden values to int so that this code works