evergreean
Technical User
How do I get the values entered to print out in my alert using a for loop?
Currently it goes through the for loop and prints the literal values. The below will print 3 literals with each fieldname only but not the values:
The script Pops up 3 alerts with literal field names:
document.tes.firstname1.value
document.tes.firstname2.value
document.tes.firstname3.value
I want it to pop up 3 alerts with each value entered.
Currently it goes through the for loop and prints the literal values. The below will print 3 literals with each fieldname only but not the values:
Code:
<script>
function myT()
{
for(var i=1;i<4;i++)
{
alert("document.tes.firstname"+[i]+".value");
//The below alert wont alert anything
//alert(document.tes.firstname[i].value);
}
}
</script>
<form name="tes" method="post" action="actionPage.cfm" onsubmit="return myT();">
<input type="Text" name="firstname1">
<input type="Text" name="firstname2">
<input type="Text" name="firstname3">
<input type="Submit" value="submit">
</form>
document.tes.firstname1.value
document.tes.firstname2.value
document.tes.firstname3.value
I want it to pop up 3 alerts with each value entered.