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 Chris Miller 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

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
 
Not too hot on VBScript, try the VBScript forum - forum329
 
Don't use vbscript, but in JavaScript you have to call the function from the button tag when the button's clicked. For example:

<input type=&quot;button&quot; onClick=&quot;btnGo_OnClick()&quot; value=&quot;Go&quot;>
 
Thanks, I'll check the VBScript forum... But to clarify, for the person who mentioned putting the call inside the object... It does work in VBScript, to just have the subroutine named appropriately. The subroutine runs, it just doesn't do what I want it to. Thanks again!

Travis
 
I'm not up on VB either but it seems to me that you'd have to have a function call attached to your button. Also, I think I'd be more inclined to use a submit tag rather than a button tag. There's always a better way...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top