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!

using variables as field names

Status
Not open for further replies.

spazman

Programmer
May 29, 2001
500
CA
I want to pass a field name to a VBScript in a web page (client side) so I call the Script MySript('Name'), the function gets the field name, but what I can't figure out is how to get the field value, I know in JavaScript it's eval('document.form.'+fieldname+'.value') but what is the syntax to do this in VBscript.

 
try the execute statement
eg:
<script language=&quot;vbscript&quot;>
Function alertFld(nameFld)
Dim newValue
newValue = &quot;something of these sorts?&quot;
execute &quot;document.frm.&quot;& nameFld &&quot;.value=newValue&quot;

End Function
</script>

<form name=&quot;frm&quot;>
<input type=&quot;text&quot; name=&quot;txt&quot; value=&quot;some value here&quot; size=&quot;25&quot;>
<input type=&quot;button&quot; value=&quot;eval It&quot; onClick=&quot;alertFld('txt')&quot;>
</form>

____________________________________________________
get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924
onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top