亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Laravel 在編輯模式中獲取選定的下拉列表

如何使用 Laravel 在編輯模式中獲取選定的下拉列表

PHP
萬千封印 2024-01-19 20:42:09
我正在使用 laravel 構建一個項目,我可以將記錄從數據庫獲取到我的模式中,但問題是每次我更新我的模式時,兩個選擇中的選項值也會隨著相同的獲取結果而增加。如何避免這種情況。在這里,我粘貼了編輯前后的兩張圖像以及我到目前為止所做的事情。請幫我完成它。之前的圖像后像我的模態部分<a href="javascript:void(0);" data-href="{{ url('admin/product_edit/'.$cat->id) }}" class="edit_product btn btn-sm btn-primary" data-toggle="modal" data-target="#editModal"> Edit</a><div class="modal" id="editModal" tabindex="-1" role="dialog" aria-labelledby="insertModalLabel" aria-hidden="true">                <div class="modal-dialog modal-lg" role="document">                    <div class="modal-content">                        <div class="modal-header">                            <h5 class="modal-title font-weight-bold" id="insertModalLabel">EditCustomer</h5>                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">                                <span aria-hidden="true">&times;</span>                            </button>                        </div>                        <div class="modal-body">                          <p><b>Please note:</b> Fields marked with <span class="control-label"></span> is mandatory</p>                          <form action="{{ url('admin/update_product') }}" method="post" class="edit_database_operation">                            @csrf                            <input class="form-control" type="hidden" name="eid" id="eid">                            {{-- <input class="form-control" type="hidden" name="brand_id" id="brand_id">                            <input class="form-control" type="hidden" name="category_id" id="category_id"> --}}
查看完整描述

1 回答

?
楊__羊羊

TA貢獻1943條經驗 獲得超7個贊

在您的 jquery 代碼中,您可以使用.append()在選擇框中附加新選項,該選項只是將新元素插入到匹配元素集中每個元素的末尾。這就是它顯示雙值的原因。

相反,使用.html()替換選擇框中的所有元素。所以你只需要改變:

?$('#eproduct_brand').append(fb);

$('#eproduct_brand').html(fb);

你也這樣做eproduct_category。


查看完整回答
反對 回復 2024-01-19
  • 1 回答
  • 0 關注
  • 145 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號