Passing variable from foreach loop to my controller in PHP Laravel










0















this is a part of my code



 @foreach($fields as $field)
<div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
<input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
<input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

<button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
</div>

@endforeach


in this part every field of my products shows.
i add a button for every field to delete the field. problem is that i can not delete the field until i get the id of that field so how do i get the id from my foreach loop to my controller?



my full code



<div class="w-100">
<form method="post" action="route('ProductEdit', ['id' => $products->id])" enctype="multipart/form-data">
csrf_field()
<div class="album">
<div class="slider">
<div class="slide slide1 mySlides">
<div>
<img src="/image/products/$products->idproduct1.jpg"/>
</div>
<div class="caption">
<input type="file" class="form-control" name="image1" id="image1" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
<button type="submit" name="submitbutton" class="btn" value="save1" style="width: 100%; height: 100%;">تغییر عکس اول</button>
</div>
</div>
<div class="slide slide2 mySlides">
<div>
<img src="/image/products/$products->idproduct2.jpg"/>
</div>
<div class="caption">
<input type="file" class="form-control" name="image2" id="image2" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
<button type="submit" name="submitbutton" class="btn" value="save2" style="width: 100%; height: 100%;">تغییر عکس دوم</button>
</div>
</div>
<div class="slide slide3 mySlides">
<div>
<img src="/image/products/$products->idproduct3.jpg"/>
</div>
<div class="caption">
<input type="file" class="form-control" name="image3" id="image3" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
<button type="submit" name="submitbutton" class="btn" value="save3" style="width: 100%; height: 100%;">تغییر عکس سوم</button>
</div>
</div>
` </div>
</div>

<button type="button" class="btn btn-primary" onclick="plusDivs(-1)">❮</button>
<button type="button" class="btn btn-primary" onclick="plusDivs(+1)">❯</button>

<div class="form-group mt-lg-5" dir="rtl">
<label for ="description">توضیحات محصول</label>
<textarea class="form-control" id="description" placeholder="Enter Your Message" maxlength="1000"></textarea>
</div>
<div>
<div>
@foreach($fields as $field)
<div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
<input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
<input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

<button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
</div>

@endforeach
</div>
<div>
<button type="submit" class="btn btn-primary mt-5" name="submitbutton" value="add-field">اضافه کردن فیلد </button>
</div>
</div>
</form>

<script src=" asset('js/slider.js') " defer></script>
</div>


and my controller



public function update(Request $request, $id)


switch($request->input('submitbutton'))

case 'save1':

$user = Auth::user();
$products = Product::findOrFail($id);
$destinationPath = public_path(). '/image/products/';

$avatarName = $products->id . 'product1' . '.' . 'jpg';
request()->image1->move($destinationPath, $avatarName);

return Redirect::back();

break;

case 'save2':



$user = Auth::user();
$products = Product::findOrFail($id);
$destinationPath = public_path(). '/image/products/';

$avatarName = $products->id . 'product2' . '.' . 'jpg';
request()->image2->move($destinationPath, $avatarName);

return Redirect::back();

break;

case 'save3':


$user = Auth::user();
$products = Product::findOrFail($id);
$destinationPath = public_path(). '/image/products/';

$avatarName = $products->id . 'product3' . '.' . 'jpg';
request()->image3->move($destinationPath, $avatarName);

return Redirect::back();

break;

case 'add-field':

$products = Product::findOrFail($id);
$products->fields()->create();

return Redirect::back();

break;


case 'del-field':



return Redirect::back();

break;














share|improve this question




























    0















    this is a part of my code



     @foreach($fields as $field)
    <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
    <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
    <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

    <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
    </div>

    @endforeach


    in this part every field of my products shows.
    i add a button for every field to delete the field. problem is that i can not delete the field until i get the id of that field so how do i get the id from my foreach loop to my controller?



    my full code



    <div class="w-100">
    <form method="post" action="route('ProductEdit', ['id' => $products->id])" enctype="multipart/form-data">
    csrf_field()
    <div class="album">
    <div class="slider">
    <div class="slide slide1 mySlides">
    <div>
    <img src="/image/products/$products->idproduct1.jpg"/>
    </div>
    <div class="caption">
    <input type="file" class="form-control" name="image1" id="image1" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
    <button type="submit" name="submitbutton" class="btn" value="save1" style="width: 100%; height: 100%;">تغییر عکس اول</button>
    </div>
    </div>
    <div class="slide slide2 mySlides">
    <div>
    <img src="/image/products/$products->idproduct2.jpg"/>
    </div>
    <div class="caption">
    <input type="file" class="form-control" name="image2" id="image2" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
    <button type="submit" name="submitbutton" class="btn" value="save2" style="width: 100%; height: 100%;">تغییر عکس دوم</button>
    </div>
    </div>
    <div class="slide slide3 mySlides">
    <div>
    <img src="/image/products/$products->idproduct3.jpg"/>
    </div>
    <div class="caption">
    <input type="file" class="form-control" name="image3" id="image3" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
    <button type="submit" name="submitbutton" class="btn" value="save3" style="width: 100%; height: 100%;">تغییر عکس سوم</button>
    </div>
    </div>
    ` </div>
    </div>

    <button type="button" class="btn btn-primary" onclick="plusDivs(-1)">❮</button>
    <button type="button" class="btn btn-primary" onclick="plusDivs(+1)">❯</button>

    <div class="form-group mt-lg-5" dir="rtl">
    <label for ="description">توضیحات محصول</label>
    <textarea class="form-control" id="description" placeholder="Enter Your Message" maxlength="1000"></textarea>
    </div>
    <div>
    <div>
    @foreach($fields as $field)
    <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
    <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
    <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

    <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
    </div>

    @endforeach
    </div>
    <div>
    <button type="submit" class="btn btn-primary mt-5" name="submitbutton" value="add-field">اضافه کردن فیلد </button>
    </div>
    </div>
    </form>

    <script src=" asset('js/slider.js') " defer></script>
    </div>


    and my controller



    public function update(Request $request, $id)


    switch($request->input('submitbutton'))

    case 'save1':

    $user = Auth::user();
    $products = Product::findOrFail($id);
    $destinationPath = public_path(). '/image/products/';

    $avatarName = $products->id . 'product1' . '.' . 'jpg';
    request()->image1->move($destinationPath, $avatarName);

    return Redirect::back();

    break;

    case 'save2':



    $user = Auth::user();
    $products = Product::findOrFail($id);
    $destinationPath = public_path(). '/image/products/';

    $avatarName = $products->id . 'product2' . '.' . 'jpg';
    request()->image2->move($destinationPath, $avatarName);

    return Redirect::back();

    break;

    case 'save3':


    $user = Auth::user();
    $products = Product::findOrFail($id);
    $destinationPath = public_path(). '/image/products/';

    $avatarName = $products->id . 'product3' . '.' . 'jpg';
    request()->image3->move($destinationPath, $avatarName);

    return Redirect::back();

    break;

    case 'add-field':

    $products = Product::findOrFail($id);
    $products->fields()->create();

    return Redirect::back();

    break;


    case 'del-field':



    return Redirect::back();

    break;














    share|improve this question


























      0












      0








      0








      this is a part of my code



       @foreach($fields as $field)
      <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
      <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
      <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

      <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
      </div>

      @endforeach


      in this part every field of my products shows.
      i add a button for every field to delete the field. problem is that i can not delete the field until i get the id of that field so how do i get the id from my foreach loop to my controller?



      my full code



      <div class="w-100">
      <form method="post" action="route('ProductEdit', ['id' => $products->id])" enctype="multipart/form-data">
      csrf_field()
      <div class="album">
      <div class="slider">
      <div class="slide slide1 mySlides">
      <div>
      <img src="/image/products/$products->idproduct1.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image1" id="image1" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save1" style="width: 100%; height: 100%;">تغییر عکس اول</button>
      </div>
      </div>
      <div class="slide slide2 mySlides">
      <div>
      <img src="/image/products/$products->idproduct2.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image2" id="image2" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save2" style="width: 100%; height: 100%;">تغییر عکس دوم</button>
      </div>
      </div>
      <div class="slide slide3 mySlides">
      <div>
      <img src="/image/products/$products->idproduct3.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image3" id="image3" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save3" style="width: 100%; height: 100%;">تغییر عکس سوم</button>
      </div>
      </div>
      ` </div>
      </div>

      <button type="button" class="btn btn-primary" onclick="plusDivs(-1)">❮</button>
      <button type="button" class="btn btn-primary" onclick="plusDivs(+1)">❯</button>

      <div class="form-group mt-lg-5" dir="rtl">
      <label for ="description">توضیحات محصول</label>
      <textarea class="form-control" id="description" placeholder="Enter Your Message" maxlength="1000"></textarea>
      </div>
      <div>
      <div>
      @foreach($fields as $field)
      <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
      <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
      <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

      <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
      </div>

      @endforeach
      </div>
      <div>
      <button type="submit" class="btn btn-primary mt-5" name="submitbutton" value="add-field">اضافه کردن فیلد </button>
      </div>
      </div>
      </form>

      <script src=" asset('js/slider.js') " defer></script>
      </div>


      and my controller



      public function update(Request $request, $id)


      switch($request->input('submitbutton'))

      case 'save1':

      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product1' . '.' . 'jpg';
      request()->image1->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'save2':



      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product2' . '.' . 'jpg';
      request()->image2->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'save3':


      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product3' . '.' . 'jpg';
      request()->image3->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'add-field':

      $products = Product::findOrFail($id);
      $products->fields()->create();

      return Redirect::back();

      break;


      case 'del-field':



      return Redirect::back();

      break;














      share|improve this question
















      this is a part of my code



       @foreach($fields as $field)
      <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
      <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
      <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

      <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
      </div>

      @endforeach


      in this part every field of my products shows.
      i add a button for every field to delete the field. problem is that i can not delete the field until i get the id of that field so how do i get the id from my foreach loop to my controller?



      my full code



      <div class="w-100">
      <form method="post" action="route('ProductEdit', ['id' => $products->id])" enctype="multipart/form-data">
      csrf_field()
      <div class="album">
      <div class="slider">
      <div class="slide slide1 mySlides">
      <div>
      <img src="/image/products/$products->idproduct1.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image1" id="image1" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save1" style="width: 100%; height: 100%;">تغییر عکس اول</button>
      </div>
      </div>
      <div class="slide slide2 mySlides">
      <div>
      <img src="/image/products/$products->idproduct2.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image2" id="image2" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save2" style="width: 100%; height: 100%;">تغییر عکس دوم</button>
      </div>
      </div>
      <div class="slide slide3 mySlides">
      <div>
      <img src="/image/products/$products->idproduct3.jpg"/>
      </div>
      <div class="caption">
      <input type="file" class="form-control" name="image3" id="image3" aria-describedby="emailHelp" style="background-color: #7f7f7f; color: #fff; height: 3em; "/>
      <button type="submit" name="submitbutton" class="btn" value="save3" style="width: 100%; height: 100%;">تغییر عکس سوم</button>
      </div>
      </div>
      ` </div>
      </div>

      <button type="button" class="btn btn-primary" onclick="plusDivs(-1)">❮</button>
      <button type="button" class="btn btn-primary" onclick="plusDivs(+1)">❯</button>

      <div class="form-group mt-lg-5" dir="rtl">
      <label for ="description">توضیحات محصول</label>
      <textarea class="form-control" id="description" placeholder="Enter Your Message" maxlength="1000"></textarea>
      </div>
      <div>
      <div>
      @foreach($fields as $field)
      <div class="flex-row d-sm-inline-flex w-100 mt-1" dir="rtl">
      <input type="text" class="form-control w-25" name="$field->idfield" id="$field->idfield" aria-describedby="emailHelp" placeholder="$field->name" />
      <input type="text" class="form-control w-50" name="$field->iddescription" id="$field->iddescription" aria-describedby="emailHelp" placeholder="$field->description" />

      <button type="submit" class="btn btn-primary" name="submitbutton" id="del-field" value="del-field">پاک کردن فیلد</button>
      </div>

      @endforeach
      </div>
      <div>
      <button type="submit" class="btn btn-primary mt-5" name="submitbutton" value="add-field">اضافه کردن فیلد </button>
      </div>
      </div>
      </form>

      <script src=" asset('js/slider.js') " defer></script>
      </div>


      and my controller



      public function update(Request $request, $id)


      switch($request->input('submitbutton'))

      case 'save1':

      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product1' . '.' . 'jpg';
      request()->image1->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'save2':



      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product2' . '.' . 'jpg';
      request()->image2->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'save3':


      $user = Auth::user();
      $products = Product::findOrFail($id);
      $destinationPath = public_path(). '/image/products/';

      $avatarName = $products->id . 'product3' . '.' . 'jpg';
      request()->image3->move($destinationPath, $avatarName);

      return Redirect::back();

      break;

      case 'add-field':

      $products = Product::findOrFail($id);
      $products->fields()->create();

      return Redirect::back();

      break;


      case 'del-field':



      return Redirect::back();

      break;











      javascript php html5 laravel-5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 14:58









      wanttobeprofessional

      1,01931323




      1,01931323










      asked Nov 12 '18 at 14:10









      Ahmad VahediAhmad Vahedi

      153




      153






















          1 Answer
          1






          active

          oldest

          votes


















          0














          <script>
          $(document).ready(function()
          var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
          $("#del-field").click(function()
          $.ajax(
          /* the route pointing to the update function */
          url: '/',
          type: 'POST',
          /* send the csrf-token and the input to the controller */
          data: _token: CSRF_TOKEN, id:$(this).val(),
          dataType: 'JSON',
          /* remind that 'data' is the response of the Controller */
          success: function (data)


          );
          );
          );
          </script>





          share|improve this answer























          • ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

            – Ahmad Vahedi
            Nov 12 '18 at 15:43











          • You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

            – Yaroslaw
            Nov 12 '18 at 21:31










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263931%2fpassing-variable-from-foreach-loop-to-my-controller-in-php-laravel%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          <script>
          $(document).ready(function()
          var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
          $("#del-field").click(function()
          $.ajax(
          /* the route pointing to the update function */
          url: '/',
          type: 'POST',
          /* send the csrf-token and the input to the controller */
          data: _token: CSRF_TOKEN, id:$(this).val(),
          dataType: 'JSON',
          /* remind that 'data' is the response of the Controller */
          success: function (data)


          );
          );
          );
          </script>





          share|improve this answer























          • ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

            – Ahmad Vahedi
            Nov 12 '18 at 15:43











          • You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

            – Yaroslaw
            Nov 12 '18 at 21:31















          0














          <script>
          $(document).ready(function()
          var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
          $("#del-field").click(function()
          $.ajax(
          /* the route pointing to the update function */
          url: '/',
          type: 'POST',
          /* send the csrf-token and the input to the controller */
          data: _token: CSRF_TOKEN, id:$(this).val(),
          dataType: 'JSON',
          /* remind that 'data' is the response of the Controller */
          success: function (data)


          );
          );
          );
          </script>





          share|improve this answer























          • ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

            – Ahmad Vahedi
            Nov 12 '18 at 15:43











          • You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

            – Yaroslaw
            Nov 12 '18 at 21:31













          0












          0








          0







          <script>
          $(document).ready(function()
          var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
          $("#del-field").click(function()
          $.ajax(
          /* the route pointing to the update function */
          url: '/',
          type: 'POST',
          /* send the csrf-token and the input to the controller */
          data: _token: CSRF_TOKEN, id:$(this).val(),
          dataType: 'JSON',
          /* remind that 'data' is the response of the Controller */
          success: function (data)


          );
          );
          );
          </script>





          share|improve this answer













          <script>
          $(document).ready(function()
          var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
          $("#del-field").click(function()
          $.ajax(
          /* the route pointing to the update function */
          url: '/',
          type: 'POST',
          /* send the csrf-token and the input to the controller */
          data: _token: CSRF_TOKEN, id:$(this).val(),
          dataType: 'JSON',
          /* remind that 'data' is the response of the Controller */
          success: function (data)


          );
          );
          );
          </script>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 14:19









          YaroslawYaroslaw

          834




          834












          • ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

            – Ahmad Vahedi
            Nov 12 '18 at 15:43











          • You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

            – Yaroslaw
            Nov 12 '18 at 21:31

















          • ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

            – Ahmad Vahedi
            Nov 12 '18 at 15:43











          • You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

            – Yaroslaw
            Nov 12 '18 at 21:31
















          ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

          – Ahmad Vahedi
          Nov 12 '18 at 15:43





          ty for your answer,i allready find code like this,problem is i don't know how to use this code or call it in my controller?

          – Ahmad Vahedi
          Nov 12 '18 at 15:43













          You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

          – Yaroslaw
          Nov 12 '18 at 21:31





          You use Laravel but do not know what Ajax is. I think you need to start with the basics of web programming.

          – Yaroslaw
          Nov 12 '18 at 21:31

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53263931%2fpassing-variable-from-foreach-loop-to-my-controller-in-php-laravel%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Use pre created SQLite database for Android project in kotlin

          Darth Vader #20

          Ondo