Results 1 to 2 of 2

Thread: Setting Resetting Radio buttons

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266

    Unhappy

    Hello there,
    I have a very simple question. I have got 2 radio buttons on a form. I am querying the database and retrieving data and accordingly trying to set/reset the radio buttons. I do not know how to set/reset the radio buttons using the document object. All help is appreciated. Thanks in advance.
    The code snippet(actually the entire asp) is given below.

    <HTML>
    <HEAD>
    Employee Information
    </HEAD>

    <BODY>

    <FORM METHOD=GET NAME="F1">
    <table>
    <tr>
    <td>Name:
    <td><INPUT TYPE=TEXT NAME="cab_name_1" MAXLENGTH=50 VALUE="" READONLY>
    <tr>
    <td>Marital Status:
    <td>
    <INPUT TYPE="RADIO" NAME="maritalstatus_1" VALUE="1" CHECKED>Married
    <INPUT TYPE="RADIO" NAME="maritalstatus_1" VALUE="0" >UnMarried
    </table>
    </FORM>

    <%
    Dim cnn, i
    Dim rscount
    Dim strValue
    Dim strquotes

    strquotes = """"
    set cnn = Server.CreateObject("ADODB.Connection")
    cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\dgoffice.mdb"
    cnn.Open
    Set rscount = cnn.Execute("SELECT * FROM tmp where page_id=225")
    For i = 0 to rscount.Fields.count - 1
    Session(i) = strquotes + CStr(rscount.fields(i).value) + strquotes
    Next
    cnn.Close
    %>

    <SCRIPT LANGUAGE=VBSCRIPT>
    Dim theForm
    Dim strtmp, j

    Set theForm = document.Forms(0)
    theForm.cab_name_1.value = <%= Session(0) %>
    <!-- Here lies my problem -->
    <!-- Now then how do I set the radio buttons. I have tried the following but it does not work -->
    if theForm.maritalstatus_1(0) = "on" then
    theForm.cab_fol_count_1.value = "ON"
    else
    theForm.cab_fol_count_1.value = "OFF"
    end if


    </SCRIPT>
    </BODY>
    </HTML>

  2. #2
    Guest

    Cool Is this the one u want?

    <html><head>
    <title>Set-Reset Radio Button</title>
    <Script Language = "VBS">
    <!--
    Sub InitForm
    document.frmOption.optTrue.checked = False
    document.frmOption.optFalse.checked = False
    End Sub

    Sub btnTest_OnClick()
    Dim fill
    fill = document.frmText.txtbox.value
    If fill = "true" Then
    document.frmOption.optTrue.checked = True
    document.frmOption.optFalse.checked = False
    Msgbox " The True Radio button is On" ,0
    ElseIf fill = "false" Then
    document.frmOption.optFalse.checked = True
    document.frmOption.optTrue.checked = False
    Msgbox " The False Radio button is On",0
    Else
    Msgbox " Nothing " , 0
    document.frmOption.optTrue.checked = True
    document.frmOption.optFalse.checked = True

    End If

    End Sub
    -->
    </Script>
    </head>
    <body onLoad = "InitForm()">
    <table border="1" width="29%" height="99">
    <tr>
    <td width="100%" height="93">
    <form name ="frmText"">

    <p><input type="text" name="txtBox" size="20" ><input type="button" value="Test" name="btnTest"></p>
    </form>
    <form name = "frmOption">
    <p><input type="radio" value="V1" name="optTrue" checked>True
    <input type="radio" name="optFalse" value="V2" >False</p>
    </form>
    </td>
    </tr>
    </table>
    </body>
    </html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width