Click here to Skip to main content
15,900,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two sets of radio buttons with group names of X and Y. in first set of radio button i have 5 radio buttons and in second set i have 2 radio buttons. My question is how to get the value or id of that radio button which i have clicked using java script and redirect that values to another page in asp.net..

my code of radio buttons as follows:
XML

1st set of radio buttons:

<td width="60%" style="padding-bottom:10px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="10%" height="20" align="center"><label>
                          <asp:RadioButton ID="transactions" runat="server" GroupName="x"/>
                        </label></td>
                        <td width="90%" class="notxt">Transactions</td>
                      </tr>
                      <tr>
                        <td height="20" align="center"><asp:RadioButton ID="unsettled" runat="server" GroupName="x"/></td>
                        <td class="notxt"> Unsettled </td>
                      </tr>
                      <tr>
                        <td height="20" align="center"><asp:RadioButton ID="settled" runat="server" GroupName="x"/></td>
                        <td class="notxt"> Settled </td>
                      </tr>
                      <tr>
                        <td height="20" align="center"><asp:RadioButton ID="gaming" runat="server" GroupName="x"/></td>
                        <td class="notxt"> Gaming </td>
                      </tr>
                      <tr>
                        <td height="20" align="center"><asp:RadioButton ID="all" runat="server" GroupName="x"/></td>
                        <td class="notxt"> All (except Games)</td>
                      </tr>
                    </table></td>

2nd set of radio buttons:

<td width="60%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="10%" height="24" align="center"><asp:RadioButton ID="last" runat="server" GroupName="y"/></td>
                    <td width="90%">
                      <select name="select" class="lm1">
                        <option>Day</option>
                        <option>1week</option>
                        <option>2week</option>
                        <option>1month</option>
                        <option>2month</option>
                        <option>3month</option>
                        <option>6month</option>
                      </select></td>
                  </tr>
                </table></td>

<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="10%" height="24" align="center">
                        <asp:RadioButton ID="from" runat="server" GroupName="y"/>
                    </td>
                    <td width="15%" class="gtxt"><strong>From</strong></td>
                    <td width="75%">
                        <asp:TextBox ID="frmtxt" runat="server" CssClass="tf"></asp:TextBox>
                        <cc1:CalendarExtender ID="CalendarExtender1"
                     TargetControlID="frmtxt" Format="MM/dd/yyyy" runat="server">
                 </cc1:CalendarExtender>
                        </td>
                  </tr>
                </table></td>
Posted
Updated 23-Sep-12 23:28pm
v2

hi,
you can write like below:

C#
var id=document.getElementById('ctl00_ContentPlaceHolder1_radiobutton');
        window.location = "http://example.com/foo.php?option="+id.value;
 
Share this answer
 
Hi,

U can try following code.

write a function following function in javascript file.

C#
function call(me) {
    if (document.forms(0).elements(me).type.toUpperCase() == "RADIO") {
        alert("yes");
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900