繁体   English   中英

再次单击下拉菜单不起作用

[英]dropdown not working when clicked a second time

我的复选框有问题。 如果我选择一个值并进行验证,则无法第二次执行该操作,这将无法正常工作。 在查看其他问题时,我发现可能必须将prop()函数与“ checked”属性一起使用,但是我仍然无法使用。

这是我的网站: 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>

您正在将checked属性设置为选择无效的框。 从您的switch case语句中删除以下几行,它应该可以工作。

$("#trainingcourses").prop('checked', false);

也不确定是否需要在此处提交按钮。 如果您需要不应该提交页面的简单按钮,则将显示按钮type="submit"更改为type="button"

暂无
暂无

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

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