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

how to cycle thru fields in a form CLIENT SIDE 1

Status
Not open for further replies.

TravisLaborde

IS-IT--Management
Nov 4, 2002
84
US
Using VBScript, and intending to run in IE6, I am trying to do something that seems simple from looking at the object model, but just isnt working...

Basically I have a form, with various INPUT tags and a BUTTON. I put VBScript code to the onClick event of the button, and I want it to cycle thru each field in the form, and take action. I'll work on the actions later, I can't even cycle thru the form yet. Please take a look at this code and help me if you can:

<body>
<form method=post id=theForm name=theForm>
<input type=text name=field_one id=field_one><br>
<input type=text name=field_two id=field_two><br>
<input type=button name=btnGO id=btnGO value=GO>
</form>
</body>
<script language=vbscript>
sub btnGo_OnClick()
for each field in document.forms(0)
msgbox field.name
next
end sub
</script>

Now, I've tried all sorts of things, including document.forms(0).children(x) whatever... no luck. I can't even get one to show up, much less cycle thru them.

Please help if you can.
Travis
 
FOR i = 0 TO document.theForm.elements.length - 1
if document.theForm.elements(i).value = &quot;&quot; then ...
if document.theForm.elements(i).name = &quot;&quot; then ...
NEXT -- Just trying to help... LOL [ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top