PC Review


Reply
Thread Tools Rate Thread

How can vbscript retrieve the "value" of selected html radio butto

 
 
=?Utf-8?B?U2NodWV5?=
Guest
Posts: n/a
 
      10th May 2005
Hi all,

I am currently writing an application involving html and vbscript. I am
building a simple html page for data acquisition, and utilize vbscript to
retrieve the data for further calculation (This html page is not posted on
web and only used on another software program). When I am dealing with html
radio button, I couldn't find a way to retrieve the "value" property of the
selected button during run time. Below are code that I use.

*****vbscript code*******
Sub OnOk() '// When click OK button, I try to retrieve "value" of selected
radio button

Dim sResult

sResult = rButtonGroup1.value '//At run time, error rappears at this line

window.returnValue = sResult

window.close

End Sub


********html code, 2 radio button*******

<input type="radio" value="V1" name="rButtonGroup1">
<input type="radio" value="V2" name="rButtonGroup1">

When I issue the OK button, error message "object does not support this
method or property" 'rButtonGroup1.value' appears. While I expect
"rButtonGroup.value" should return either value V1 or V2. Can anyone give me
some advice about this?

Thanks for your kind attention

Schuey

 
Reply With Quote
 
 
 
 
MD Websunlimited
Guest
Posts: n/a
 
      10th May 2005
Hi Schuey,

You have to walk the array looking for the checked element.

sub findradio_click()

dim i


for i = 0 to document.radiofind.group1.length - 1

if document.radiofind.group1(i).checked then

msgbox document.radiofind.group1(i).value

end if

next

end sub


"Schuey" <(E-Mail Removed)> wrote in message news:7E9DA5B6-2341-4C12-B3D3-(E-Mail Removed)...
> Hi all,
>
> I am currently writing an application involving html and vbscript. I am
> building a simple html page for data acquisition, and utilize vbscript to
> retrieve the data for further calculation (This html page is not posted on
> web and only used on another software program). When I am dealing with html
> radio button, I couldn't find a way to retrieve the "value" property of the
> selected button during run time. Below are code that I use.
>
> *****vbscript code*******
> Sub OnOk() '// When click OK button, I try to retrieve "value" of selected
> radio button
>
> Dim sResult
>
> sResult = rButtonGroup1.value '//At run time, error rappears at this line
>
> window.returnValue = sResult
>
> window.close
>
> End Sub
>
>
> ********html code, 2 radio button*******
>
> <input type="radio" value="V1" name="rButtonGroup1">
> <input type="radio" value="V2" name="rButtonGroup1">
>
> When I issue the OK button, error message "object does not support this
> method or property" 'rButtonGroup1.value' appears. While I expect
> "rButtonGroup.value" should return either value V1 or V2. Can anyone give me
> some advice about this?
>
> Thanks for your kind attention
>
> Schuey
>



 
Reply With Quote
 
=?Utf-8?B?U2NodWV5?=
Guest
Posts: n/a
 
      11th May 2005
Dear Mike,

Thanks for your help, it works and my problem is basically solved.

Just something I don't understand. I found that method
"document.radiofind." is not supported , therefore, I take off all
"document.radiofind."and use code like Group1(0).checked, Group1(0).value .
Obviously, method Group1.length is not supported. This makes the For...Next
statement a bit awkward since I have to hardcode the loop number. I also
tried Group1().length but still not succeed. Are there any alternative way
to retrieve gourp length? Following is code that involves.

<script LANGUAGE="VBScript">

Sub OnOk()

for i = 0 to 2 '\\Hardcode loop number for 3 radio button

if group11(i).checked then

msgbox group1(i).value

window.returnValue = group1(i).value

end if

next

window.close

End Sub

</script>

<table CELLPADDING="1" CELLSPACING="2" BORDER="0">

<input type="radio" value="Value 1" name="group1">
<input type="radio" value="Value 2" name="group1">
<input type="radio" value="Value 3" name="group1">

</table>

Thanks a lot

Schuey

"MD Websunlimited" 來函:

> Hi Schuey,
>
> You have to walk the array looking for the checked element.
>
> sub findradio_click()
>
> dim i
>
>
> for i = 0 to document.radiofind.group1.length - 1
>
> if document.radiofind.group1(i).checked then
>
> msgbox document.radiofind.group1(i).value
>
> end if
>
> next
>
> end sub
>
>
> "Schuey" <(E-Mail Removed)> wrote in message news:7E9DA5B6-2341-4C12-B3D3-(E-Mail Removed)...
> > Hi all,
> >
> > I am currently writing an application involving html and vbscript. I am
> > building a simple html page for data acquisition, and utilize vbscript to
> > retrieve the data for further calculation (This html page is not posted on
> > web and only used on another software program). When I am dealing with html
> > radio button, I couldn't find a way to retrieve the "value" property of the
> > selected button during run time. Below are code that I use.
> >
> > *****vbscript code*******
> > Sub OnOk() '// When click OK button, I try to retrieve "value" of selected
> > radio button
> >
> > Dim sResult
> >
> > sResult = rButtonGroup1.value '//At run time, error rappears at this line
> >
> > window.returnValue = sResult
> >
> > window.close
> >
> > End Sub
> >
> >
> > ********html code, 2 radio button*******
> >
> > <input type="radio" value="V1" name="rButtonGroup1">
> > <input type="radio" value="V2" name="rButtonGroup1">
> >
> > When I issue the OK button, error message "object does not support this
> > method or property" 'rButtonGroup1.value' appears. While I expect
> > "rButtonGroup.value" should return either value V1 or V2. Can anyone give me
> > some advice about this?
> >
> > Thanks for your kind attention
> >
> > Schuey
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: GroupBox and Radio Buttons - Want Default to be "Not Selected" PvdG42 Microsoft VB .NET 1 28th Nov 2009 02:15 AM
RE: GroupBox and Radio Buttons - Want Default to be "Not Selected" OmegaSquared Microsoft VB .NET 1 27th Nov 2009 06:51 PM
Virus? PC said "we have given birth" then "we'll leave it here" nowplays a radio station in the background steveyweveyboy@gmail.com Anti-Virus 0 24th Feb 2009 10:44 AM
retrieve Active cell "Name" vbscript Lee Microsoft Excel Programming 3 19th Feb 2009 06:29 PM
Equivalient of VBScript's "Eval" and "Execute" statements Mike Microsoft ASP .NET 2 4th Oct 2004 11:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 PM.