Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将单选按钮功能转换为复选框_Java_Jsp_Jstl - Fatal编程技术网

Java 将单选按钮功能转换为复选框

Java 将单选按钮功能转换为复选框,java,jsp,jstl,Java,Jsp,Jstl,我有两个单选按钮 <span class="text_content">Td:</span> <INPUT TYPE="radio" NAME="lastTetanusType" value="Td" <c:if test="${emergencyContactInfo.lastTetanusType == 'Td' || emergencyContactInfo.lastTetanusType == null}">checked</c:if>

我有两个单选按钮

<span class="text_content">Td:</span>
<INPUT TYPE="radio" NAME="lastTetanusType" value="Td"
<c:if test="${emergencyContactInfo.lastTetanusType == 'Td' || emergencyContactInfo.lastTetanusType == null}">checked</c:if> >

 <span class="text_content">Tdap:</span>
 <INPUT TYPE="radio" NAME="lastTetanusType" value="Tdap"
<c:if test="${emergencyContactInfo.lastTetanusType == 'Tdap'}">checked</c:if> >
Td:
Tdap:
现在我想将这些单选按钮转换为复选框,其功能可以是null、null、one或两者都选中。
如果我只选中了一个复选框,那么值
emergencyContactInfo.lastTetanusType=Td
,如果我选择第二个选项,即
emergencyContactInfo.lastTetanusType=Tdap
的值,最后如果我同时选择这两个选项,则选择
emergencyContactInfo.lastTetanusType=Td/Tdap
的值,您可以将每个单选按钮放在单独的
单选组中
。因此,您可以同时单击这两个按钮,也可以单击任意一个按钮。

单选按钮可以通过其类别进行识别 因此,在你的案例中,你只需要将他们的类分开,
我认为“
name
”属性就可以了。

您有方法
replaceWith()

$(':radio')。每个(函数(){
var$newCheckbox=$('').attr({name:this.name,value:this.value});
$(this).replacetwith($newCheckbox);
});

你想说什么,伙计? 现在我了解到,您希望将单选按钮更改为复选框 非单选按钮的行为类似于复选框X 那好吧 将您的类型更改为
复选框

simpel演示::

<!DOCTYPE html>
<html>
<body>

<form action="">
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car 
</form>

</body>
</html>

我有一辆自行车
我有一辆车

我想要复选框而不是单选按钮我想要复选框而不是单选按钮。这很好,但您尝试了什么?我尝试了一些jquery功能,但没有成功。但是新功能呢。
<!DOCTYPE html>
<html>
<body>

<form action="">
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car 
</form>

</body>
</html>