当我从“请求编号”下拉列表中选择一个选项时,如何将值设置为数据库中的customerNumber(Marketing表中的字段)?
<div class="col-sm-2">
<label class="label" for="request_id">Request Number:</label>
<select class="form-control option" id="request_id">
<option >0 - Request Number</option>
@foreach ($customer_requests as $customer_request)
<option value={{$customer_request->id}}>{{$customer_request->id}} -{{$customer_request->requestNumber}} </option>
@endforeach
</select>
</div>
<div class="col-sm-2">
<label class="label" for="customerNumber" >Customer Number:</label>
<input type="text" class="form-control text" id="customerNumber" name="customerNumber">
</div>
我是一个laravel的学习者,我想知道jQuery是否应该使用?如何使用?
<script>
$("#request_id").on({
click: function() {
}, keypress: function() {
$( this ).addClass( "inside" );
var val = $(this).val();
var data = Marketing::find(val);
$("#customerNumber").attr("value", data[customerNumber] );
}
});
</script>
1条答案
按热度按时间2guxujil1#
对于jquery,您可以尝试如下:
然后,创建一个新控制器来返回customerNumber。类似于: