Category : checkbox

I wanna input checkbox with value 0 and 1, if i checked value 1, and if not checked value 0. my code in View @foreach($criteria as $data) <table> <tr> <td class="col-4"> <input type="hidden" name="criteria_id[]" value="{{ $data->id }}"> { $data->criteria_name}} : </td><br> <td class="col-2"> <input type="hidden" class="form-control" name="score[]" value="0"> <input type="checkbox" class="form-control" name="score[]" value="1"> </td> </tr> ..

Read more

I’m trying to save multiple Label Text of Checkboxes. First, I’m saving chechbox value in a column of database table. But other than that, I have to save Label of each those checkbox checked in another column of table. My table: Schema::create(‘restaurant_offers’, function (Blueprint $table) { $table->increments(‘id’); ……. $table->string(‘additionalOptions’)->nullable(); $table->string(‘additionalOptionsSum’)->nullable(); …… }); My blade: <label ..

Read more

I’m trying to fetch all my checkboxes with additional column from pivot table. Model: Stock class Stock extends Model { public function products(){ return $this->belongsToMany(‘AppProduct’,’products_stock’)->withPivot(‘qtySpent’)->withTimestamps(); } } Model: Products class Product extends Model { public function stocks(){ return $this->belongsToMany(‘AppStock’,’products_stock’)->withPivot(‘qtySpent’)->withTimestamps(); } } Pivot: product_stock Schema::create(‘product_stock’, function (Blueprint $table) { $table->bigIncrements(‘id’); $table->integer(‘product_id’); $table->foreign(‘product_id’) ->references(‘id’) ->on(‘products’)->onDelete(‘cascade’); $table->integer(‘stock_id’); $table->foreign(‘stock_id’) ..

Read more

I’m working with SweetAlert2 to show a confirmation box to user, if he checks a checkbox on a form like this: <form id="from1" data-flag="0" action="" method="POST"> @csrf <input type="checkbox" name="wallet_checked" onchange="this.form.submit();"> </form> As you can see I have used onchange="this.form.submit();" for checkbox in order to submit the form without using submit button and it works ..

Read more

I’m trying to submit a form with javascript, I need that when verifying a checkbox send the form automatically, in a few seconds. <form method="POST" action="{{ route(‘turnox’, $event->id) }}"> {{ method_field(‘PUT’) }} @csrf <div class="row"> <div class="col"> Confirmar Asistencia: </div> <div class="col"> <label class="switch s-icons s-outline s-outline-success mr-2"> <input name="cconfirma" type="checkbox"> <span class="slider round"></span> </label> ..

Read more

i have created the form normally, but after I want to parse the data into index, there is data is not showed normally.. This a code for model Form protected $guarded = []; public function user(){ return $this->hasOne(‘AppUser’, ‘id’, ‘user_id’); //Product Model Name } public function location(){ return $this->hasOne(‘AppLocations’, ‘id’, ‘location_id’); } public function purpose(){ ..

Read more

there is a controller to save orders and there is some checkbox inputs . i try to explain that if that input is checked … some code must be run. but in any conditional mode $debatorprice, $payment and $kalaf are returned null public function store(Request $request) { if ($request[‘image’]){ $file = $request[‘image’]; $imgname = $file->getClientOriginalName(); ..

Read more

I have a problem with checkbox. When I click the update button, it will change all the values of the column into 1 while I want only the checked one to become 1. Here is my form: <form action="{{ route(‘restaurant.saveCheckUpdatedItems’) }}" method="POST" enctype="multipart/form-data"> @csrf <td><input type="checkbox" id="checked" name="checked[]" value=""></td> Controller: $items = ItemReservationItem::whereIn(‘restaurant_id’, $restaurantIds)->get(); for($i=0; ..

Read more

I created a form in laravel where I want to add 2 checkboxes that when creating the post to display on or off in the database. So far we have managed to create the post if the checkbox is checked in the database. But I don’t know exactly how to do it for the negative ..

Read more

“` here is controller public function edit_pay($id){ $where = array(‘id’ => $id); $arr =[]; $users = PaymentMethod::where($where)->first(); $checked_arr = explode(" ",$users->purpose_of_used); return view(‘payment_method.edit_pay’)->with(compact(‘users’,’checked_arr’)); } enter code here <input type="checkbox" name="method[]" value={{ array_has($checked_arr, $users->purpose_of_used) ? "checked" : "" }}>Purchase <input type="checkbox" name="method[]" value={{ array_has($checked_arr, $users->purpose_of_used) ? "checked" : "" }}> Gift Card <input type="checkbox" name="method[]" value={{ ..

Read more

When im input using checkbox for value windows 7 & 10 it doesn’t get into the database. But input in part <– other –>, it can enter into database Views Code : <div class="form-group col-md-12"> <label>OS :</label> <div class="checkbox-list"> <label class="form-group col-md-4"> <input id="os" name="os" type="radio" value="Windows 7"> <span></span> Windows 7 </label> <label class="form-group col-md-4"> ..

Read more

I am filtering my products by colors in my Laravel 8 application. And I want to send a get request. Here are my colors <label class="w-full flex items-center space-x-2"> <span> <input type="checkbox" onChange="this.form.submit()" name="colors[]" value="{{$color->id}}" @if(in_array($color->id, $selectedColors)) checked @endif /> </span> <span class="block -mt-1 select-none"> {{$color->title}}</span> </label> Now the result I am getting from this ..

Read more

I have a checkbox <input type="checkbox" name="example"> The user submits the form and return back due to failed validation so I want to show the previous state of the checkbox <input type="checkbox" name="example" {!! old(‘example’) ? ‘value="1" checked’ : ‘value="0"’ !!}> First question here is that, what to do with validation now? if it was ..

Read more

I would like to learn how to update a form component like Checkbox without having to refresh the page in laravel. blade.php <form id="canview"> <fieldset> <div class="checkbox checkbox-success"> <input type="checkbox" id="canViewBox{{$key}}" onChange="this.form.submit()" @if($document->pivot->canview == 1) checked @endif> <label for="canViewBox{{$key}}"></label> </div> </fieldset> </form> <script type="text/javascript"> $(‘#canview’).on(‘submit’,function(event){ event.preventDefault(); $.ajax({ url: "/switchme", type:"POST", data:{ "_token": "{{ csrf_token() }}", ..

Read more

i m trying to get the number of the students filtered by campus, year and group with checkbox. this is my view. <div class="col-sm-6"> <div class="form-group"> <label class="col-sm-3">Campus</label> <div class="col-sm-9"> <div class="col-xs-6"> <div class="checkbox checkbox-danger"> <input type="checkbox" name="campus" value="1" id="1"> <label for="1"> Campus1</label> </div> </div> <div class="col-xs-6"> <div class="checkbox checkbox-danger"> <input type="checkbox" name="campus" value="2" id="2"> ..

Read more

i written a very simple code to update value of checkbox but it update 1 in db on uncheck it doesnot update 0 if request is submit here is code <div class="form-group"> <label>If it is checked it means user can only create given customer order.</label> <input type="checkbox" id="js-switch" name="customer_itself" @if($ot->customer_itself == 1) checked @endif> </div> ..

Read more

I get this error, when I submit the form SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘onloan’ cannot be null Please help. Sorry for the noob question. I’ve been searching but the examples are different. edit.blade.php <div class="form-group"> <input type="checkbox" class="" id="onloan" value="1" {{ $item->onloan == 1 ? ‘checked’ : ” }}> <label for="onloan">On Loan</label> </div> ..

Read more