如果我单击打印按钮,我想显示选定的复选框值
这是我的代码
<! DOCTYPE html>
<head>
<script type="text/javascript">
function checkbox()
{
var bk=document.getElementById("bk").value;;
var cer=document.getElementById("cr").value;
document.writeln(" " + bk );
document.write(" " + cer);
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="bk" name="vehicle" value="Bike">I have a bike<br></br>
<input type="checkbox" id="cr" name="vehicle" value="Car">I have a car<br></br>
<input type="submit" value=" Print " size="30" onClick="checkbox()">
</form>
</body>
</html>
如果我选择 Bike 复选框并单击打印按钮,它应该显示唯一的 Bike。