input check复选框选择后修改标签超链接href


1. 给复选框添加onclick事件 获取标签id

 1     <tbody>
 2                         <c:forEach var="file" items="${files}">
 3                         <tr class="er" onMouseMove="changeTrColor(this)">
 4                             <td class="xuanze"><input type="checkbox" name="r" value="${file.id}" onclick="aa()"/></td>
 5                             <td class="name">${file.filename}</td>
 6                             <td class="daxiao">15k</td>
 7                             <td class="time"><a href="#">2015-01-01</a> <select><option>删除</option><option>移动到</option><option>复制到</option><option>下载</option></select></td>
 8                         </tr>
 9                       </c:forEach>
10                     </tbody>

2。给a标签添加id

1   <div class="btn2">
2             <a href="#" id="xiazai">下载</a>
3             <a href="#">删除</a>
4             <a href="#">打印</a>
5         </div>

3.获取复选框id修改href属性

 1 function aa(){
 2     alert("aa");
 3     var r=document.getElementsByName("r"); 
 4     for(var i=0;i<r.length;i++){
 5          if(r[i].checked){
 6          alert(r[i].value);
 7          var num = r[i].value;
 8          document.getElementById("xiazai").href="file/download?id="+num;
 9        }
10     }     
11 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM