how to access dinamically named form fields in vbscript?

W

wolfing1

So the html looks like this:
<%@ Language="VBScript" %>
<%Option Explicit %>
<html> <head>...</head> <body>
<form name="myform">
<table>
<% for x=1 to 10
response.write "<tr><td><input type=checkbox name=ch"+cstr(x)+"
onclick='vbscript:call f("+cstr(x)+") </td></tr>"
%>
</table>
</form>
</html>

And I want to create a sub in vbscript kinda like this:
<SCRIPT LANGUAGE="VBScript">
option explicit
sub f(x)
dim myform
set myform=Document.myform
if myform.?.checked then '? means I don't know how to do it
msgbox("checked")
end if
end sub
</SCRIPT>
How can I reference the form field dinamically instead of the usual
myform.field.value?
 
W

wolfing1

So the html looks like this:
<%@ Language="VBScript" %>
<%Option Explicit %>
<html> <head>...</head> <body>
<form name="myform">
<table>
<% for x=1 to 10
response.write "<tr><td><input type=checkbox name=ch"+cstr(x)+"
onclick='vbscript:call f("+cstr(x)+") </td></tr>"
%>
</table>
</form>
</html>

And I want to create a sub in vbscript kinda like this:
<SCRIPT LANGUAGE="VBScript">
option explicit
sub f(x)
dim myform
set myform=Document.myform
if myform.?.checked then '? means I don't know how to do it
msgbox("checked")
end if
end sub
</SCRIPT>
How can I reference the form field dinamically instead of the usual
myform.field.value?

Nevermind, found the answer myself. Using document.getelementbyid
works like a charm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top