我的复选框有问题。如果我选择一个值并进行验证,我不能再次这样做,它就无法正常工作。看看其他问题,我看到我可能必须使用prop()函数和"检查"财产,我做了,但它仍然没有工作。
这是我的网站:http://nts.nuvision.co.za/index.php/training/
这是我的javascript:
$('#one').hide();
$('#two').hide();
$('#three').hide();
$('#show').click(function() {
$('#pgc-224-0-1').css("margin-top", "0px");
switch(document.getElementById('trainingcourses').value) {
case 'one':
$('#one').show();
$('#two').hide();
$('#three').hide();
$("#trainingcourses").prop('checked', false);
break;
case 'two':
$('#two').show();
$('#one').hide();
$('#three').hide();
$("#trainingcourses").prop('checked', false);
break;
case 'three':
$('#three').show();
$('#two').hide();
$('#one').hide();
$("#trainingcourses").prop('checked', false);
break;
}
});
这是我的HTML:
<form id="trainingform">
<select id="trainingcourses" style="font-size: 12pt;">
<option style="font-size: 12pt;" value="one">Sugar and Suite CRM End User Training</option>
<option style="font-size: 12pt;" value="two">Sugar & Suite CRM Advanced End User Training</option>
<option style="font-size: 12pt;" value="three">Sugar and Suite CRM Administrator : Getting Started</option>
</select><input id="show" style="margin-top: -25px; margin-left: 20px;" name="show" type="submit" value="Show more information" onclick="location.href='http://nts.nuvision.co.za/index.php/training/#' + document.getElementById('trainingcourses').value; return false;"/></form>
<div id="one"> (...) </div>
<div id="two"> (...) </div>
<div id="three"> (...) </div>
答案 0 :(得分:0)
您正在设置checked
属性以选择无效的框。从switch case语句中删除下面的行,它应该可以工作。
$("#trainingcourses").prop('checked', false);
此外还不确定您是否需要提交按钮。如果您需要不提交页面的简单按钮,请将显示按钮type="submit"
更改为type="button"
。