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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping throught the controls on an html form

Status
Not open for further replies.
Aug 9, 2001
1
US
Dear All

I would like to find out if there is a way of loop through an HTML form in order to two add up the values in a number of text boxes. The number of text boxes are not fixed and not named consistantly.

Your help will be much appreciated.

Thanks
John

 
U have to use JavaScript...
Like this
<HTML>
<BODY>
<input id=text1 name=text1><br>
<input id=text2 name=text2><br>
<input id=text3 name=text3><br>
<input id=text4 name=text4><br>
<input id=text5 name=text5><br>
</BODY>
<script language=javascript>
var coll = document.all.tags(&quot;INPUT&quot;);
if (coll!=null)
{
for(i=0;i<coll.length;i++)
coll.value=&quot;value &quot;+i;
};
</script>
</HTML>

in VBScript i dont know if this is possible ________

George
 
This is probably a stupid question, but I understand each line of your script except this:

coll.value=&quot;value&quot; +i;

what is in &quot;value&quot; that you are adding i to?

 
This line add an string to the textboxes
&quot;value&quot; could be anything else...

coll.value=&quot;My textbox number &quot; +i;
________

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top