三文鱼
三文鱼
  • 发布:2016-10-12 16:11
  • 更新:2016-10-12 17:36
  • 阅读:1243

accordion中 多个折叠框中的表单提交互不影响怎么实现?

分类:MUI

问题描述:
参照accordion.html做的带有表单输入的折叠面板,如图所示,ul下的每个li都是动态生成的

function fillData(rows, length, realCheckName) {  
                    var innerHTMLContent = '';  
                    for(var i = 0; i < length; i++) {  
                        var locationName = rows[i].locationName;  
                        var workShopName = rows[i].workShopName;  
                        var machineName = rows[i].machineName;  
                        var machineModel = rows[i].machineModel;  
                        var locationName = rows[i].locationName;  
                        var keyPointName = rows[i].keyPointName;  
                        var method = rows[i].methodName;  
                        var rules = rows[i].rules;  
                        var detailId = rows[i].detailId;  
                        innerHTMLContent += formatInnerHTML(locationName, workShopName, machineName, machineModel, locationName, keyPointName, method, rules, realCheckName, detailId)  
                    }  
                    document.getElementById("fillDataList").innerHTML = innerHTMLContent;  

                    var submitBtn = doc.getElementById('submitBtn');  
                    var detailIdHid = doc.getElementById('detailIdHid').value;  
                    submitBtn.addEventListener('tap', function(event) {  
                        alert(detailIdHid);  
                    });  
                }  

//组装ul下的每个li  
        function formatInnerHTML(locationName, workShopName, machineName, machineModel, locationName, keyPointName, method, rules, realCheckName, detailId) {  

                    var innerHtmlContent = "<li class='mui-table-view-cell mui-collapse'>" +  
                        "<a class='mui-navigate-right'  href='#'>" + locationName + "</a>" +  
                        "<div class='mui-collapse-content'>" +  
                        "<form class='mui-input-group'>" +  
                        "<input type='text' id='detailIdHid' value=" + detailId + ">" +  

                        "<div class='mui-button-row'>" +  
                        "<button class='mui-btn mui-btn-primary' style='width:100px;height:35px;font-size: 16px;' type='button' id='submitBtn'>提&nbsp;&nbsp;交</button>&nbsp;&nbsp;" +  
                        "<button class='mui-btn mui-btn-primary' style='width:100px;height:35px;font-size: 16px;' type='button'>取&nbsp;&nbsp;消</button>" +  
                        "</div>" +  
                        "</form>" +  
                        "</div>" +  
                        "</li>"  
                    return innerHtmlContent;  
                }

问题:

                var submitBtn = doc.getElementById('submitBtn');  
                var detailIdHid = doc.getElementById('detailIdHid').value;  
                submitBtn.addEventListener('tap', function(event) {  
                    alert(detailIdHid);  
                });  

这段代码只能获取第一个li的内容 后面的获取不到 请问如何解决

2016-10-12 16:11 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

你只获取第一个li的value值,其他的肯定不会弹出来了,可以用循环获取每个li的value值,放在一个数组中

该问题目前已经被锁定, 无法添加新回复