【问题标题】:how to keep the checkbox checked and disabled once it is submitted through form通过表单提交后如何保持复选框处于选中状态和禁用状态
【发布时间】:2017-09-18 10:19:44
【问题描述】:

我是我的表单,我有一个复选框列表,在这里我想显示选中的复选框,如果它被选中并提交一次,则禁用它。

这是我的代码,

@if(!empty($sublaws))
    <ul style="list-style:none;">
    <li class="law_{{ $law->id }}">
        <input type="checkbox" name="law_type_id[]" id="law_type_id{{ $law->id }}" class="delclass" value="{{ $law->id }}" reldeltype="{{ $law->id }}" />
        <strong>{{ $law->lm_id }} ( {{ $law->law_name }} )</strong>
        <ul style="list-style:none;">
            @foreach ($sublaws as $sublaw)
                <li>
                    <input type="checkbox" name="law_sub_type_id[]" id="law_sub_type_id{{$sublaw->id}}" value="{{$sublaw->id}}" class="delsubclass" reldeltype="{{ $law->id }}" reldelsubtype="{{$sublaw->id}}" />
                    {{ $sublaw->lms_id }} ( {{ $sublaw->sub_law_name }} )</li>
            @endforeach
        </ul>
    </li>
   </ul>
@endif

【问题讨论】:

  • 提交一次是什么意思?提交后页面是否保持不变?
  • 你可以使用输入复选框属性checked="checked"来检查复选框
  • @HimanshuUpadhyay 是的,我的表单与复选框列表保持一致
  • 您可能正在使用 ajax 提交表单?
  • @HimanshuUpadhyay 是的

标签: javascript php jquery checkbox


【解决方案1】:
$("#IdofYourCheckbox").prop('checked', true);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-29
    • 2019-09-12
    相关资源
    最近更新 更多