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