none
repeater中怎么通过js获取radiobuttonlist的值,可通过【按第一项设置】使下一个radiobuttonlist拥有相同的值 RRS feed

  • 问题

  • js 代码通过table完成的:
     function SetData()
        {
            var table;
            ///是CRCT还是CRCF,true为CRCT,fasle为CRCF
            var isCrct = true;
            if($get('tblCRCFtable') == null)
            {
                alert("单据出现脚本错误,请联系管理员。");
                window.close();
                return false;
            } 
            else 
            {
                table = $get('tblCRCFtable');            
            }
                    var the_td3 = table.rows[1];    
                    var the_td4 = table.rows[2]; 
                    var the_td5 = table.rows[3]; 
              for (var i = 4; i < table.rows.length; i+=3) 
             {
                    var the_tr = table.rows[i];
                    var the_tr1 = table.rows[i+1];
                    var the_tr2 =table.rows[i+2];
                    for (var j = 0; j < the_tr.cells.length; j++) 
                    {
                  
                        var the_td = the_tr.cells[j];    
                        if (the_td.children != null && the_td.children[0] != null&&the_td3.cells[j].children != null && the_td3.cells[j].children[0] != null) 
                        {
                            for(var u =0; u < the_td.children.length; u++)
                            {
                                 var the_ele = the_td.children[u];
                                 the_ele.value =   the_td3.cells[j].children[u].value;            
                            }
                        }
                    }
    //下面是获取radiobuttonlist的值,结果 the_td4.cells[j].children[u].value无定义
                     for (var j = 0; j < the_tr1.cells.length; j++) 
                    {
                        var the_td1 = the_tr1.cells[j];    
                        if (the_td1.children != null && the_td1.children[0] != null&&the_td4.cells[j].children != null && the_td4.cells[j].children[0] != null) 
                        {
                            for(var u = 0; u < the_td1.children.length; u++)
                            {
                                var the_ele1 = the_td1.children[u];
                                the_ele1.value =   the_td4.cells[j].children[u].value;             
                            }
                        }
                    }
                    for (var j = 0; j < the_tr2.cells.length; j++) 
                    {
                        var the_td2 = the_tr2.cells[j];    
                        if (the_td2.children != null && the_td2.children[0] != null&&the_td5.cells[j].children != null && the_td5.cells[j].children[0] != null) 
                        {
                            for(var u = 0; u < the_td2.children.length; u++)
                            {
                                var the_ele2 = the_td2.children[u];
                                the_ele2.value =   the_td5.cells[j].children[u].value;             
                            }
                        }
                    }
             }  
            return false;
        }

    后台代码:
      RadioButtonList rdList = e.Item.FindControl("Reason") as RadioButtonList;
                        if (rdList.Items.Count <= 0)
                        {
                            //绑定RadioButtonList内容
                            rdList.DataTextField = "ReasonType";
                            rdList.DataValueField = "ID";
                            List<DICAttendaneConfirmation> ltACObjtmp = DICAttendaneConfirmationAdapter.Instance.List();
                            List<DICAttendaneConfirmation> ltACObj = new List<DICAttendaneConfirmation>();
                            foreach (DICAttendaneConfirmation obj in ltACObjtmp)
                            {
                                ltACObj.Add(obj);
                            }
                            rdList.DataSource = ltACObj;
                            rdList.DataBind();



    页面编译代码
        <tr>
                                                <th align="right" style="vertical-align:middle; line-height: 20px;" nowrap="nowrap">
                                                    原因<span class="heightlightPoint" style="background-color: #e6e6fa">(*)</span><span
                                                        style="color: #ff0000">:
                                                </th>
                                                 <td rowspan ="1" class="moduleTitle" style="!important" colspan="4">
                                                <div id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_setDiv" class="rblStyle" style="width:500px;">
                                                    <table id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason" border="0" style="border-style:None;width:98%;overflow: hidden;">
    <tr>
    <td><input id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_0" type="radio" name="ctl00$ContentPlaceHolder1$CRCFRepeater$ctl01$Reason" value="1" checked="checked" /><label for="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_0">忘打卡</label></td><td><input id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_1" type="radio" name="ctl00$ContentPlaceHolder1$CRCFRepeater$ctl01$Reason" value="2" /><label for="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_1">忘带卡</label></td><td><input id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_2" type="radio" name="ctl00$ContentPlaceHolder1$CRCFRepeater$ctl01$Reason" value="3" /><label for="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_2">外出</label></td><td><input id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_3" type="radio" name="ctl00$ContentPlaceHolder1$CRCFRepeater$ctl01$Reason" value="4" /><label for="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_3">出差</label></td><td><input id="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_4" type="radio" name="ctl00$ContentPlaceHolder1$CRCFRepeater$ctl01$Reason" value="5" /><label for="ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_4">其他(此选项备注必填)</label></td><td></td>
    </tr>
    </table>
    、、、、、、、、、、页面逻辑代码不明白,为什么只出现一个ctl00_ContentPlaceHolder1_CRCFRepeater_ctl01_Reason_0 明明添加了两个
    2017年6月29日 2:48

答案

全部回复

  • Hi haozy,

    感谢你在MSDN论坛发帖。

    如果你想获取被选中的值,你可以参考下面的方式。

    https://forums.asp.net/t/1761822.aspx?Get+Selected+value+of+Radiobutton+list+in+repeater+to+save+in+database

    https://stackoverflow.com/questions/6702658/get-selected-radio-button-list-value-from-radio-buttons-inside-a-repeater

    不太清楚你的项目是否与ASP.NET 有关系,如果是ASP.NET的项目,我建议你去ASP.NET论坛发帖,这样会得到更好的帮助。下面是ASP.NET的论坛地址。

    https://forums.asp.net/

    我将把你的帖子移到一般性讨论论坛,如果你的问题已经得到解决,请即使标记有用的回复作为答案,这样会帮助遇到相同问题的人。

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 haozy 2017年6月29日 6:17
    2017年6月29日 5:36
    版主
  • 好 Hart Cheng:

      你给出的见解是关于repeater中获取radiobuttonlist的值在后台获得,这一点我明白,而且已经做到。但是现在的需求要求是设置一个功能点:【按第一项设置】用于对这一行内容的复制到其余行上去,我在repeater中设置table标签数据值的抓去,对于表中的账户,日期,备注抓去都是没问题的但是对原因radiobuttonlist ID=reason就不行了

    这些我都希望通过js完成这个功能点

    2017年6月29日 6:16