Text 启用和禁用文本字段的复选框
问题是我有很多文本字段60-70 我需要做的是,当复选框被取消选中时,文本输入应该被禁用,当复选框被选中时,文本输入被启用Text 启用和禁用文本字段的复选框,text,input,checkbox,Text,Input,Checkbox,问题是我有很多文本字段60-70 我需要做的是,当复选框被取消选中时,文本输入应该被禁用,当复选框被选中时,文本输入被启用 当复选框被取消勾选时,它应该禁用该字段并将其清除。使用javascript可以做到这一点 $('.checkbox').each(function(a,b){ $(b).click(function(){ if($(this).is(':checked')){ $(this).next('.textfield').removeAttri
当复选框被取消勾选时,它应该禁用该字段并将其清除。使用javascript可以做到这一点
$('.checkbox').each(function(a,b){
$(b).click(function(){
if($(this).is(':checked')){
$(this).next('.textfield').removeAttribute('disabled');
}else{
$(this).next('.textfield').attr('disabled','disabled').val('');
}
});
});
<html>
<body>
<script type="text/javascript">
function textInput() {
if (document.inputForm.checkbox.checked) {
document.inputForm.input.disabled=false;
} else {
document.inputForm.input.disabled=true;
}
}
</script>
<form name="inputForm">
<label>Enable Input</label>
<input type="checkbox" name="checkbox" onclick="textInput()">
<label> Input:</label>
<input type="text" name="input" disabled="true">
</form>
</body>
</html>
您使用的是什么语言/工具包?如果是jquery,请编写您需要帮助的代码。它可以正常工作,但我需要textbos name作为value send。还有其他方法吗?@user2614879发送值需要文本框名称是什么意思?我的意思是我的名称=权限[],权限[]是我需要发送到的数组mysql@user2614879我不认为在表单中发送名称并同时使用javascript有什么问题。如何在输入字段中使用它?