dynamic for loop

Z

ziemon

i have this :


for (i = 0; i < test.length; i++)
{
document.write("#" + test.number + test.name + test.height +
test.position + test.college + "<br>")
}


my question is how can i make 'test' dynamic ? so that i can specify for
example through a form which array (the name) it should be?

tnx
 
E

Evertjan.

ziemon wrote on 07 sep 2003 in comp.lang.javascript:
for (i = 0; i < test.length; i++)
{
document.write("#" + test.number + test.name + test.height +
test.position + test.college + "<br>")
}

my question is how can i make 'test' dynamic ? so that i can specify
for example through a form which array (the name) it should be?


<script>
function writest(x) {
for (i = 0; i < x.length; i++) {
t = "#" + x.number + x.name
t += x.height + x.position
t += x.college + "<br>"
document.writeln(t)
}
}

writest(test1)
writest(test2)

</script>

not writested
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top