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!

Why cant I reference radio button?

Status
Not open for further replies.

JanS

Technical User
Feb 21, 2001
77
AU
I have a group of radio buttons. I cannot reference these individually unless I give them unique names. Not what I want to do.

If I reference the object using the following syntax, I get an error saying "object does not support property or method"

sValue = window.CriteriaPg.rState.value

If I use this syntax, I get this message "Expected end of statement" as the page is loaded

sValue = window.CriteriaPg.rState[0].value

Why cant I reference the individual radio buttons so I can read their value??

I also need to understand what the problem is as I need to be able to set the checked status of individual radio buttons.

HELP!!! - much appreciated
jan

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<SCRIPT language=&quot;vbscript&quot;>
sub GetSchool()
sValue = window.CriteriaPg.rState[0].value 'or rState.value
msgbox sValue
end sub
</SCRIPT>
</HEAD>
<BODY >
<H1>Test Page</H1>

<FORM id=CriteriaPg>
<INPUT id=rState name=rState type=radio value=ACT checked>ACT
<INPUT id=rState name=rState type=radio value=NSW>NSW
</FORM>
<INPUT type=&quot;button&quot; value=&quot;Button1&quot; id=button1 name=button1 onclick=&quot;vbscript:call getschool()&quot;>
</BODY>
</HTML>
 
Ah... have you tried using parentheses instead of brackets for specifying an index? You might also want .checked instead of .value (you have value hard-coded, it will always be &quot;ACT&quot;).

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<SCRIPT language=&quot;vbscript&quot;>
sub GetSchool()
sValue = window.CriteriaPg.rState(0).checked
msgbox sValue
end sub
</SCRIPT>
</HEAD>
<BODY >
<H1>Test Page</H1>

<FORM id=CriteriaPg>
<INPUT id=rState name=rState type=radio value=ACT checked>ACT
<INPUT id=rState name=rState type=radio value=NSW>NSW
</FORM>
<INPUT type=&quot;button&quot; value=&quot;Button1&quot; id=button1 name=button1 onclick=&quot;vbscript:call getschool()&quot;>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top