net中选定单选按钮的ID

net中选定单选按钮的ID

本文介绍了如何使用JavaScript获取asp.net中选定单选按钮的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两组单选按钮,组名称分别为X和Y.在第一组单选按钮中,我有5个单选按钮,在第二组中,我有2个单选按钮.我的问题是如何获取使用Java脚本单击的单选按钮的值或id,并将该值重定向到asp.net中的另一页.
我的单选按钮代码如下:

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:


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>

推荐答案

var id=document.getElementById('ctl00_ContentPlaceHolder1_radiobutton');
        window.location = "http://example.com/foo.php?option="+id.value;


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


这篇关于如何使用JavaScript获取asp.net中选定单选按钮的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 10:35