Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Depending on Select option change others value on div and input field in Laravel

I'm in the learning period. I need a solution but I couldn't find it.

I have a dynamic select option. I want that, when the select option is changed it will show all the related columns from the database in another div.

DB Table Name: Offers

Column Name: id, name, details, recharge

Controller:

$offers = Offer::all();
return view('sim_sale', compact('offers'));

Blade File:

<select name="offer_id" id="offer" class="form-control">
    <option value=""> Select Offer</option>
    @foreach ( $offers as $row )
    <option value="{{ $row->id }}">{{ $row->name }}</option>
    @endforeach
</select>
 <div id="offer-details">
     {{$offers->details}
 </div> 
 <input type="text" value="{{$offers->recharge}}" id="offer-recharge" />

Here, if the select option changes, it will show the details and recharge, else nothing will show in these fields. Also, Users can put data in the input field.

Please help me to solve it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have figured out a solution for this. Here is my code:

 <select name="offer_id" id="parent_id" class="form-control dynamic" data-dependent="details">
       <option value=""> Select Offer</option>
       @foreach ( $offers as $row )
       <option value="{{ $row->id }}">{{ $row->name }}</option>
       @endforeach
       </select>
       @foreach($offers as $row)  
       <div class="some"  id="some_{{ $row->id }}"  style="display:none;">
        {{ $row->details }}
       </div>
       @endforeach

<script type="text/javascript">
$('#parent_id').on('change',function(){
$(".some").hide();
var some = $(this).find('option:selected').val();
$("#some_" + some).show();}); </script>
                            
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!