【问题标题】:Input form disable when one is select选择一个时禁用输入表单
【发布时间】:2014-11-17 07:27:08
【问题描述】:

我有一个简单的表格。 2 个输入和 3 个单选按钮。

我需要做这样的事情:

  • 当我单击第一个输入(并开始键入)时,第二个输入和收音机被禁用,当我单击收音机时,输入被禁用。等等。

我的表单

 <form method="get">
                <div class="singleTableForm">
                    <label style="width: 95px; line-height: 25px;">Who:</label>
                    <div style="float:left;margin-right:10px;">
                        <input name="filter_task_who" value="{{ taskWho }}" id="filter_task_date" style="width: 60px;">
                    </div>
                    <label style="width: 90px; line-height: 25px;">Task ID:</label>
                    <div style="float:left;margin-right:10px;"> 
                        <input name="filter_task_id" value="{{ taskId }}" id="filter_task_date" style="width: 100px;">
                    </div>
                    <label style="width: 50px; line-height: 25px;">Priority:</label>
                    <div >
                <div style="float:left;"><input {% if filter_enabled=="Filtruj" and taskPriority==2%}checked="checked"{% endif %} style="float:left;margin-top: 5px;" type="radio" name="filter_task_priority" id="filter_task_date" value="2"><label style="width: 45px; line-height: 25px;">High</label></div>
                <div style="float:left;"><input {% if filter_enabled=="Filtruj" and taskPriority==1%}checked="checked"{% endif %} style="float:left;margin-top: 5px;" type="radio" name="filter_task_priority" id="filter_task_date" value="1"><label style="width: 45px; line-height: 25px;">Medium</label></div>
                <div style="float:left;"><input {% if taskPriority != null %}{% if filter_enabled=="Filtruj" and taskPriority==0%}checked="checked"{% endif %}{% endif %} style="float:left;margin-top: 5px;" type="radio" name="filter_task_priority" id="filter_task_date" value="0"><label style="width: 45px; line-height: 25px;">LOW</label></div>
                    </div>
                    <div style="float: left;width:90px; " >
                    <a style="float: left;margin-left: 2px;padding-left: 6px;padding-right: 6px;padding-top: 1px;padding-bottom: 1px;" type="submit" href="{{path('admin_tasks')}}" class="button">Reset</a>
                    <input style="float: left;" type="submit" name="filter_enabled" class="button" value="Filtruj" />
                </div>
                </div>


            </form>

【问题讨论】:

  • 您想在单击第一个输入时禁用第二个输入和单选按钮?
  • 我不明白。
  • 很高兴您需要这样做,但是您尝试过什么?
  • 如果您单击单选按钮并禁用输入,如果需要,您打算如何重新启用?
  • 我更新了我的问题。当我单击一个输入并开始键入第二个输入时,收音机被禁用

标签: jquery forms disabled-input


【解决方案1】:

使用focusfocusout 事件并将disabled 的属性更改为true 或false:

$("#filter_task_date1").focus(function (){
    $("#filter_task_date2").prop('disabled', true);
    $("#filter_task_date3").prop('disabled', true);
    $("#filter_task_date4").prop('disabled', true);
    $("#filter_task_date5").prop('disabled', true);
});

我还在末尾用数字更改了您的组件 ID:http://jsfiddle.net/aqbp1e9o/

【讨论】:

  • 就是这样,非常感谢!
【解决方案2】:

尝试:

$('.form1').find(':input').prop('disabled', true);*/
$('.form2').fadeTo( "slow", 0.20 );

【讨论】:

    猜你喜欢
    • 2014-11-11
    • 1970-01-01
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 2013-05-09
    相关资源
    最近更新 更多