【问题标题】:Select2 - There is no selected value in the selection field after clicking the submit buttonSelect2 - 点击提交按钮后选择字段中没有选中值
【发布时间】:2018-05-17 08:23:30
【问题描述】:

我的选择有问题。当我选择选项并单击提交按钮时,所选值将丢失。

 {{ Form::open(['url' => route('index'), 'method' => 'GET', 'class' => 'form']) }}
                {{ csrf_field() }}
<select class="form-control select2" data-tags="true" data-placeholder="Select filter" data-allow-clear="true" name="filterClients" id="filterClientBy" style="width: 100%;">
<option></option>
<option name="firstCalling" value="firstCalling" {{Request::has('firstCalling')?'selected':''}}>First callin</option>
<option name="firstVisit" value="firstVisit"{{Request::has('firstVisit')?'selected':''}}>First visit</option>
</select>
<button type="submit" id="apply" class="btn btn-success">Apply filters</button>
  {{ Form::close() }}
这段代码只是我的代码的一部分...... 提交后没有值。如何解决? `

【问题讨论】:

    标签: javascript select filter jquery-select2


    【解决方案1】:

    &lt;form action="name of file or #" method="post or get "&gt;代替&lt;form&gt;

    【讨论】:

    • @Emy 这个答案有帮助吗?
    【解决方案2】:

    form submit 是一种页面刷新。尝试使用 ajax 请求 submit 表单

    <form onsubmit="yourFunctionName()"> 
    // rest of the form
    </form>
    
    function yourFunctionName(e){
        event.preventDefault();
        //here ajax code to submit the form value
      }
    

    【讨论】:

    • 提交后框内不显示选中值的问题
    猜你喜欢
    • 1970-01-01
    • 2016-05-31
    • 2014-07-29
    • 2016-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    相关资源
    最近更新 更多