locked
Question and answer Module RRS feed

  • Question

  • User810354248 posted

    I have a aspx+vb+sql web page in which i was trying to make a question form.

    I have radio button list with Yes and No

    Hy.txt have Yes and No

    hy1.txt have Yes and No

    score.text

    i want to make a score out of this

    If hy.text selected is Yes and hy1.text selected value is No then score should be 1

    aspx page

    <asp:RadioButtonList ID="hy" runat="server" RepeatDirection="Horizontal" AutoPostBack="True">
        <asp:ListItem>Yes</asp:ListItem>
        <asp:ListItem>No</asp:ListItem>
        </asp:RadioButtonList> 

    <asp:RadioButtonList ID="hy1" runat="server" RepeatDirection="Horizontal" AutoPostBack="True">
        <asp:ListItem>Yes</asp:ListItem>
        <asp:ListItem>No</asp:ListItem>
        </asp:RadioButtonList> 

    Sunday, December 27, 2020 7:02 AM

Answers

  • User-939850651 posted

    Hi Baiju EP,

    If you want to calculate the score, you could try the OnSelectedIndexChanged event.

    This is a simple demo:

    <body>
        <form id="form1" runat="server">
            <div>
                <asp:RadioButtonList ID="hy" runat="server" RepeatDirection="Horizontal" 
    OnSelectedIndexChanged="hy_SelectedIndexChanged" AutoPostBack="True"> <asp:ListItem>Yes</asp:ListItem> <asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> <asp:RadioButtonList ID="hy1" runat="server" RepeatDirection="Horizontal"
    OnSelectedIndexChanged="hy_SelectedIndexChanged" AutoPostBack="True"> <asp:ListItem>Yes</asp:ListItem> <asp:ListItem>No</asp:ListItem> </asp:RadioButtonList> <asp:TextBox runat="server" ID="score"></asp:TextBox> </div> </form> </body>
    Protected Sub hy_SelectedIndexChanged(sender As Object, e As EventArgs)
            If hy.SelectedValue = "Yes" Xor hy1.SelectedValue = "Yes" Then
                score.Text = 1
            ElseIf hy1.SelectedValue = "Yes" And hy.SelectedValue = "Yes" Then
                score.Text = 2
            Else
                score.Text = 0
            End If
        End Sub

    Result:

    If I misunderstood something, could you provide more details?

    Best regards,

    Xudong Peng

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 28, 2020 6:29 AM