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!

Radio Button

Status
Not open for further replies.

brent01

Technical User
Jul 11, 2001
32
GB
I am creating a small form page using HTML and using VBScript to perform some actions using the data entered in the form.

The form contains 4 Radio Buttons to allow the selection of a server - HTMOA1, LONOA1, LONOA4, DUK0A1.
I have added the VBScript Sub Routine that is called when one of the Radio Button is selected. It sets a variable named 'server'. I know this works as I added a MsgBox command to my script to display the value of the radio button selected.

My problem is, that once all the entries in the form are completed and the Submit button clicked, another VBScript routine runs to perform specified actions. One of the actions should use the 'server' variable set when the Radio Button for Server Name is selected. It seem that this variable is no longer available or recognized.

Here's the code for the radio buttons and some of the form.


<INPUT TYPE= &quot;RADIO&quot; NAME= &quot;typeServer&quot; LANGUAGE= &quot;VBScript&quot;
OnClick= &quot;SetServer('HTMOA3')&quot; value=&quot;13&quot; checked>
<font face=&quot;Arial&quot;>HTMOA3 (Swan Valley)    
<INPUT TYPE= &quot;RADIO&quot; NAME= &quot;typeServer&quot; LANGUAGE= &quot;VBScript&quot;
OnClick= &quot;SetServer('LONOA1')&quot; value=&quot;12&quot;>LONOA1 (LMS)    
<INPUT TYPE= &quot;RADIO&quot; NAME= &quot;typeServer&quot; LANGUAGE= &quot;VBScript&quot;
OnClick= &quot;SetServer('LONOA4')&quot; value=&quot;2&quot;>LONOA4 (Flagship)    
<INPUT TYPE= &quot;RADIO&quot; NAME= &quot;typeServer&quot; LANGUAGE= &quot;VBScript&quot;
OnClick= &quot;SetServer('DUKOA1')&quot; value=&quot;3&quot;>DUKOA1 (Dockers)</font></BLOCKQUOTE>


<!--
Dim Server
Sub SetServer (Server)
MsgBox (Server)
End Sub
-->

</SCRIPT><BLOCKQUOTE><BLOCKQUOTE> <SCRIPT LANGUAGE =&quot;VBScript&quot;>
<!--
Sub Button1_OnClick
MsgBox (Server)


This is not the code that I want to appear after the Sub Button1_OnClick, but effectively it is at this point that I want to reference the 'server variable' set by the radio button and use this variable at several different stages in the VBScript. The MsgBox just produces an empty box at present.

Any ideas how I can select the radio button and have the 'server variable available at any stage rather than just in the Sub SetServer sub routine?

Thanks.
 
Try this:
Code:
<script language=&quot;vbs&quot;>
myServer = &quot;&quot;    'public variable available to all subs...

sub setServer(serverName)
  myServer = serverName
end sub

sub checkForm()
  select case myServer
    case 'HTMOA3'

    case 'LONOA1'

    case else

  end select
end sub
</script>
-- What did you expect? This is FREE advice. LOL[ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top