I want to show the value of a form on clicking of a checkbox and after selecting a checkbox I want that one of our input box of my form which is disabled show the name of checkbox in that field.I also want to get the id of that checkbox. I am working in laravel .
我想在点击一个复选框时显示一个表单的值,然后在选中一个复选框之后,我想要禁用我的表单中的一个输入框,显示该字段中的复选框名称。我还想得到一个ID那个复选框。我在laravel工作。
<table class="table table-bordered" style="width: 80%;margin:5% 10%;background:slateblue">
<tr>
<th>#</th>
<th>item</th>
<th>item name</th>
<th>Added_at</th>
<tr>
<?php $i=1 ?>
@foreach($items as $item)
<tr>
<td><input type="checkbox" id="bought" name="{{$item->item_name}}" class="checkbox1"></td>
<td>{{$item->id}}</td>
<td>{{$item->item_name}}</td>
<td>{{$item->date}}
</tr>
@endforeach
</table>
<form class="shopped" method="post" action="{{url('post-data')}}" hidden><br>
{!! csrf_field()!!}
<h4 align="center">Add some information to mark as shopped</h4>
<label for ="item">Items</label>
<input type="text" class ="item" disabled><br>
<label for ="price">Price</label>
<input type="text" name="price"><br>
<label for ="store_name">Store</label>
<input type="text" name="store_name"><br>
<input type="submit" value="Add as purchased" class="btn btn-info" style="margin:20px 0 20px 60px"><br>
</form>
My Jquery Code....
我的Jquery代码....
$('.checkbox1').on('change',function(e){
e.preventDefault();
var a = this.name;
$('.item').attr('val',a);
$('.shopped').show();
});
1 个解决方案
#1
1
Try this:
尝试这个:
$('.checkbox1').on('change',function(e){
e.preventDefault();
var a = this.name;
$('.item').val(a);
$('.shopped').show();
});
#1
1
Try this:
尝试这个:
$('.checkbox1').on('change',function(e){
e.preventDefault();
var a = this.name;
$('.item').val(a);
$('.shopped').show();
});