簡體   English   中英

HTML javascript復選框功能

[英]HTML javascript checkbox function

我有一個場景,當我選中 Bills Available 復選框時,應彈出圖像上傳相機功能。 我可以稍后為“圖像上傳”編寫來的函數。 但是當我檢查“可用賬單”時,我需要顯示“圖片上傳”

function calc()
{
var update=false;
console.log("update is" + update);
}

<td><input class="pop" id="exp" type="checkbox"  name="bill available" value="" onchange="calc();"/>Bill available<br></td>

像這樣:

window.onload = function() {
   document.getElementById("exp").onclick = function() {
     document.getElementById('upload').className = this.checked ? '' : 'hide';
   }
}

 window.onload = function() { document.getElementById("exp").onclick = function() { document.getElementById('upload').className = this.checked ? '' : 'hide'; } }
 .hide { display: none }
 <input class="pop" id="exp" type="checkbox" name="bill_available" value="" /><label for="exp">Bill available</label> <div class="hide" id="upload">Upload</div>

清理后使用您的代碼:

 window.onload = function() { document.getElementById("exp").onclick = function() { document.getElementById('upload').className = this.checked ? '' : 'hide'; } }
 .hide { display: none }
 <table> <tr> <td> <input class="pop" id="exp" type="checkbox" name="bill_available" value="" /> <label for="exp">Bill available</label> </td> <td class="hide" id="upload"> <img id="p2" src="./images/camera 40.PNG" style="width:30px;height:30px;" onclick="window.location='4s.html'" /><b>Image Upload</b> </td> </tr> </table>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM