Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable help

Status
Not open for further replies.
Nov 28, 2002
121
US
x value is passed into the function. It just gives a size value.
Within my for loop, I can't do the below.

document.myform.list" + i + ".checked = true;

//I ultimately want
document.myform.list1.checked = true;
document.myform.list2.checked = true;
document.myform.list3.checked = true;
//etc....until it reaches size x


<script language='Javascript'>
var checkflag = 'false';
function APPLYALL(x)
{
if (checkflag == 'false')
{
for (int i=0; i < x; i++)
{


if (document.myform.listi)
{
document.myform.list&quot; + i + &quot;.checked = true;
document.myform.NewRev&quot; + i + &quot;.value = document.myform.F4101Part.value;

}
checkflag = 'true';
return 'Uncheck All';
}

}
</script>
 
parseInt(x) prior to using it as a numeric value. I'm assuming that is the problem. you can't use strings (as all values are passe in javascript) as a numeric pointer

_____________________________________________________________________
[sub]You can accomplish anything in life, provided that you do not mind who gets credit.
Harry S. Truman[/sub]
onpnt2.gif

 
Try:
Code:
document.myform.elements[&quot;list&quot; + i].checked = true;
 
or eval(&quot;document.myform.list&quot; + i + &quot;.checked = true&quot;);

on error goto hell
 
I get an error on this line. Saying that I need a ; somewhere in there. Is this line invalid?



for (int i=0; i < x; i++)
 
didn't see the int. get rid of it. what are you trying to do with it anyhow?

_____________________________________________________________________
[sub]You can accomplish anything in life, provided that you do not mind who gets credit.
Harry S. Truman[/sub]
onpnt2.gif

 
Oh my GOSH!
This bad boy works.


<script language='Javascript'>
var checkflag = 'false';
var i = 0;
function APPLYALL(x)
{

if (checkflag == 'false')
{
for (i=0; i<x; i++)
{

if (document.myform.elements[&quot;list&quot; + i])
{
document.myform.elements[&quot;list&quot; + i].checked = true;
document.myform.elements[&quot;NewRev&quot; + i].value = document.myform.F4101Part.value;

}
}
checkflag = 'true';
return 'Uncheck All';
}

}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top