ADD or Remove Dynamic dependent select box Laravel

Questions : ADD or Remove Dynamic dependent select box Laravel

86

This is a simple Dynamic form so that I programming can select a country from the first Learning select box it will load all states of Earhost that country in each row. It was working most effective fine for the first row but when I click wrong idea Add More and select another country for use of case the next row it was loading the last United selected row states in all Modern rows. Expected Results

http://demo.webslesson.info/demo-add-remove-dynamic-dependent-drop-down-box/

Create.blade.php

<!DOCTYPE _OFFSET);  html>
<html>
<head>
    (-SMALL  <link rel="stylesheet" _left).offset  type="text/css" arrowImgView.mas  href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
 (self.     <script equalTo  src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
 make.right.     <table class="table" mas_top);  id="dynamicTable12">
        ImgView.  <tr>
          
            <th ReadIndicator  scope="col" _have  width="250">Country</th>
       .equalTo(       <th scope="col" make.top  width="250">State</th>
        OFFSET);  </tr>
        <tr>
          (TINY_    
            <td>
               .offset   <select name="country[0]" mas_right)  class="form-control js" id="state" ImgView.  required="required">
                 Indicator     <option value="">-- Select Read  Project --</option>
               _have       @foreach ($countries as $key => .equalTo(  $value)
                    <option make.left  value="{{ $key }}">{{ $value *make) {  }}</option>
                    straintMaker  @endforeach
                ^(MASCon  </select>
            </td>
 onstraints:             <td>
                mas_makeC  <select name="state[0]" [_topTxtlbl   class="form-control js">
             (@(8));         <option>-- Sub equalTo  Head--</option>
                 width.  </select>
            </td>
 make.height.             <td><button (SMALL_OFFSET);  type="button" name="add" id="add12" .offset  class="btn btn-success">Add (self.contentView)  More</button></td>
         .left.equalTo  </tr>
    </table>

    make.top  <script type="text/javascript">
   *make) {       $(document).ready(function () {

   ntMaker            SConstrai  $(document.body).on("change.select2", ts:^(MA  "select[name^='country']", function () Constrain  {
                var id_country = _make  $(this).val();
                var token iew mas  = $("input[name='_token']").val();
      catorImgV            $.ajax({
                    ReadIndi  url: "<?php echo route('select-ajax')  [_have  ?>",
                    method: ($current);  'GET',
                    dataType: entity_loader  'json',
                    data: { _disable_  id_country: id_country, _token: token libxml  },
                    success: function $options);  (data) {
                        ilename,  $("select[name^='state'").html('');
     ->load($f                     $domdocument  $("select[name^='state'").html(data.options);
 loader(false);                     }
                _entity_  });
            });
        });
     libxml_disable  </script>

    <script>

    $current =      let initializeSelect2 = function ()  10\\ 13.xls .  {
            $('.js').select2();
       File\\ 18\'   }
        var i = 0;
        /Master\\ 645  $("#add12").click(function () {
         user@example.     ++i;
            scp not2342  $("#dynamicTable12").append('<tr>  13.xls  <td> <select  18 10  class="form-control js" name="country[' File sdaf  + i + ']" /tmp/Master'  required="required"><option com:web  value="">--select--</option>@foreach user@example.  ($countries as $key => scp var32  $value)<option value="{{ $key  18 10 13.xls  }}">{{ $value id12  File  }}</option>@endforeach</select></td> web/tmp/Master  <td> <select name="state[' + i example.com:  + ']" class="form-control scp user@  js"><option>-- Sub $val  Head--</option></select></td><td><button left hand  type="button" class="btn btn-danger right side val  remove-tr">Remove</button></td></tr>');
 data //commnets             initializeSelect2()
        //coment  });
        $(document).on('click', !node  '.remove-tr', function () {
            $mytext  $(this).parents('tr').remove();
        nlt means  });

        $(document).ready(function umv val  () {
            initializeSelect2()
    sort val      });
    shorthand  </script>
</body>
</html>

ajax-select.blade.php

<option value="0">--- Select hotkey  Sub-Head more update  ---</option>
@if(!empty($states))
 valueable   @foreach($states as $key => $value)
 catch     <option value="{{ $key }}">{{ tryit  $value }}</option>
  do it  @endforeach
@endif

Controller

public function create()
    {
        while  $countries = then  DB::table('projects')->pluck("name","id")->all();
 var          return node value  view('create',compact('countries'));
    updata  }

 public function selectAjax(Request file uploaded   $request) { 
        
        no file existing  if($request->ajax()){ $states = newdata  DB::table('project_heads')->where('project_id',$request->id_country)->pluck("head","id")->all(); newtax  
        $data = syntax  view('ajax-select',compact('states'))->render(); variable  
        return val  response()->json(['options'=>$data]); save new  } } 
    
    }
Total Answers 1
27

Answers 1 : of ADD or Remove Dynamic dependent select box Laravel

Replace This following code

<script type="text/javascript">
   datfile       $(document).ready(function () {

   dataurl           notepad++  $(document.body).on("change.select2", notepad  "select[name^='country']", function () emergency  {
                var id_country = embed  $(this).val();
                var token tryit  = $("input[name='_token']").val();
      demovalue            $.ajax({
                    demo  url: "<?php echo route('select-ajax') mycodes  ?>",
                    method: reactjs  'GET',
                    dataType: reactvalue  'json',
                    data: { react  id_country: id_country, _token: token nodepdf  },
                    success: function novalue  (data) {
                        texture  $("select[name^='state'").html('');
     mysqli                     mysql  $("select[name^='state'").html(data.options);
 user                     }
                urgent  });
            });
        });
    ugent  </script>

with this

<script type="text/javascript">
   vendor       $(document).ready(function () {

   thin           little  $(document.body).on("change.select2", lifer  "select[name^='country']", function () gold  {
                var id_country = transferent  $(this).val();
                var el = hidden  $(this)
                var token = overflow  $("input[name='_token']").val();
        padding          $.ajax({
                    new pad  url: "<?php echo route('select-ajax') pading  ?>",
                    method: html  'GET',
                    dataType: panda  'json',
                    data: { py  id_country: id_country, _token: token python  },
                    success: function proxy  (data) {
                       udpport  el.closest("tr").find("select[name^='state']").html(''); ttl                     
             rhost  el.closest("tr").find("select[name^='state']").html(data.options);
 text                     }
                path  });
            });
        });
    new  </script>

Hope :)

Top rated topics

System.Printing in .NET 5

How to create this multiple scatter plots in mclust package in r?

Mocking or bypassing authorization when testing .NET Core Web API application

How can I upload Images with Preview in React

How to sort datetiems based on only month and day using list (not pandas)?

Reading struct/union members from a character buffer

Add row-break to PowerPoint add-in

Tailwind css font-family classes are not rendering as they should

`seq` takes a very long time with `by=1`

Dynamically pull values from nested form using Gravity Forms &amp; Gravity Wiz Nested Forms

Is there a way to make a flutter switch button keep printing until the button is clicked again(disabeled)

Reference in B2C_1A_TrustFrameworkExtensions missing in Identity Experience Framework examples

MapEither inserting both Left and Right

I can't use JQuery Plugin Croppie. Getting "croppie is not a function" error

Criteria Builder using JPA Specification Predicate issue

AWS IAM is failing with missing permissions that are unrecognized by AWS

Ngxs dispatch completes before async action completes

Detecting changes in lit sub-properties

How can I define a custom style to an ARB text?

With TLS, Does the Transport layer comes after the DNS and again after the data is ready to add the TCP header?

Navigate through table pagination with Html Agility Pack (HAP)

How do I listen custom js window events in dart 2.15 / flutter 2.8

Strange behavior of pivot_table() with different "index" parameter

Import library in BigQuery through UDF

How can I import a table in MATLAB with footer rows?

JavaMail: Setting Outlook Categories after reading a message

NodeJS Error - Cannot set headers after they are sent to the client

Citibank credentials not accepted when entered using Selenium

Dynamic Pull Request Preview environment on Google App Engine

Running Multiple call stacks/apps

Mocking a request with a payload using wiremock

Multi Threading python 3.7

How to send an HTTP request with authorization token using C#

Get generic type of class at runtime with Python 3.6

Render img element for each of the IDs in multiple arrays

SQL Server - Pivot without aggregation

Cannot read properties of undefined (reading 'value')

Keras layer to perform operation across data within a batch

How do I write my own challenge_auth method for aiosmtpd?

How to put the dates in chronological order in python CSV

What is wrong with this constructor definition?

When a user clicks a button, how do you store a variable that can be used later?

IMASDK new ad request on different video

Postgres unique or exclusion constraint for partial index on conflict fails to update tickets

I used two 'setState' inside a handleChange of input, for searching on the array. why the search is unseccesfull?

Storybook in React project display keys of the translations, not the values

Possible JMeter bug when using JDBC Connection over SSH?

Failed to open port using ansible

Drop character from first or the last

SQL query to count unique csv in a table

Top