简体   繁体   English

如何在提示中将值放入此复选框的值?

[英]How can I get the value in the prompt put it in the value of this checkbox?

How can I get the value in the prompt put it in the value of this checkbox? 如何在提示中将值放入此复选框的值?

<script type=text/javascript>   
function validate(d){
        if(document.getElementById('chk'+d).checked){
        var value = prompt("Enter Correct Quantity:", "");
            if(isNaN(value)){ 
                alert("Must be a Integer!");
            }else{
                if(value == ""){
                    value = null;
                }
                if(value!=null){
                    document.getElementById("value"+d).innerHTML=value; 
                }
            }
        }
    }
</script>

I want to put the 'value' in the function validation to the value of the checkbox. 我想将功能验证中的“值”放入复选框的值。

<br><input id='chk"+d+"' type='checkbox' name='error_"+d+"[]' onclick='validate("+d+")' value=''>Wrong Quantity&nbsp;<em id='value"+d+"'></em>

Your suggestions will be most appreciated. 您的建议将不胜感激。

Check it on http://jsfiddle.net/yVN78/ http://jsfiddle.net/yVN78/上进行检查

Lots of html coding mistakes. 许多html编码错误。

<input id='chk1' type='checkbox' name='error_1' onclick='validate("1")' value=''>Wrong Quantity&nbsp;<em id='value1'></em>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM