not getting data in laravel 5.4 controller of dynamically created array of form input using jquery in view...












0















I have created a form in view file of my laravel 5.4 app where i can add more input fields using jquery clone() function. in this form i also use jquery select2 plugin.
Here is form:



<form name="tempform" action="{{route('temppris.store')}}" method="POST">
{{csrf_field()}}
<table class="table table-hover small-text" id="tb">
<tr class="tr-header">
<th >Sl.No.</th>
<th class="col-lg-2" >Type</th>
<th class="col-lg-3">Medicine Name</th>
<th colspan="2" class="col-lg-2">Dosage</th>
<th colspan="2" class="col-lg-2">Duration</th>
<th>Total Qty</th>
<th class="col-lg-1"> Remarks</th>
<th><a href="javascript:void(0);" style="font-size:18px;" id="addMore" title="Add More Person"><span class="glyphicon glyphicon-plus"></span></a></th>
<tr>
<td><input type="text" name="slno" style="width:100%;" readonly></td>
<td ><select name="meditype" class="meditype" style="width:100%;"></select> </td> </td>
<td class="col-lg-4"><select name="medicine" class="medicine" style="width:100%;"></select></td>
<td><input type="number" value="1" class="dos input-sm" style="width:40px;" min="1" name="dos" step="0.1"></td>
<td class="col-lg-2"><select class="dosage" style="width:100%;" name="dosage" ></select></td>

<td><input type="number" value="1" class="NoOfDuration input-sm" style="width:40px;" min="1" name="NoOfDuration" min="1"></td>
<td class="col-lg-2"><select class="duration" name="duration" style="width:100%;"></select></td>
<td><input type="number" class=" total" min="1" name="total" style="width:50px;"></td>

<td class="col-lg-2"><select name="remarks" class="remarks" style="width:100%;"></td>
<td><a href='javascript:void(0);' class='remove'><span class='glyphicon glyphicon-remove'></span></a></td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<label>Doctor Advice</label>
<textarea name="docadvice" id="docadvice" class="form-control"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<button type="submit" class="form-control btn btn-success">Save Template</button>
<input type="hidden" name="doc_id" value="{{Auth::user()->doc_id}}">
</div>
</div>
</div>

</form>


Here is my jquery codes:



$('#addMore').on('click', function() {
$(".meditype").select2('destroy');
$(".medicine").select2('destroy');
$(".remarks").select2('destroy');
$(".duration").select2('destroy');
$(".dosage").select2('destroy');
var data = $("#tb tr").last().clone(true).appendTo("#tb");
data.find("input").val('');
data.find("select").val('');


I am a noob in controller code. so how can i get values of my all elements of form in controller . including those are dynamically created using jquery. i tried many times but only get null value or just value of first row. in jquery i initialize my select2 elements on form loading and also reinitialize them after cloning. so its working fine while i clone it. It may work for others because I search for this but not found on internet. But now getting values of this form in controller became headache for me. Trying from last 3 days but not working.
UPDATE
Here is Codes I am trying just for checking:



 $count=count($request->get('medicine'));
$temppris->medicines=$count;
$medicine=$request->get('medicine');
foreach($medicine as $index => $value)
{
$tempmedicine=new tempmedicine;
$tempmedicine->medicine_dosage=$medicine[$index]=>$value;
$tempmedicine->save();
}









share|improve this question

























  • if anyone have any solution. but need more view of codes please ask her. thanks if you help..

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:13











  • Can you post the controller code you are trying?

    – F.Igor
    Nov 24 '18 at 8:17











  • here is codes i trying.

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:51











  • i Updates codes i am trying just to check . can you suggest where am i wrong??

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:55
















0















I have created a form in view file of my laravel 5.4 app where i can add more input fields using jquery clone() function. in this form i also use jquery select2 plugin.
Here is form:



<form name="tempform" action="{{route('temppris.store')}}" method="POST">
{{csrf_field()}}
<table class="table table-hover small-text" id="tb">
<tr class="tr-header">
<th >Sl.No.</th>
<th class="col-lg-2" >Type</th>
<th class="col-lg-3">Medicine Name</th>
<th colspan="2" class="col-lg-2">Dosage</th>
<th colspan="2" class="col-lg-2">Duration</th>
<th>Total Qty</th>
<th class="col-lg-1"> Remarks</th>
<th><a href="javascript:void(0);" style="font-size:18px;" id="addMore" title="Add More Person"><span class="glyphicon glyphicon-plus"></span></a></th>
<tr>
<td><input type="text" name="slno" style="width:100%;" readonly></td>
<td ><select name="meditype" class="meditype" style="width:100%;"></select> </td> </td>
<td class="col-lg-4"><select name="medicine" class="medicine" style="width:100%;"></select></td>
<td><input type="number" value="1" class="dos input-sm" style="width:40px;" min="1" name="dos" step="0.1"></td>
<td class="col-lg-2"><select class="dosage" style="width:100%;" name="dosage" ></select></td>

<td><input type="number" value="1" class="NoOfDuration input-sm" style="width:40px;" min="1" name="NoOfDuration" min="1"></td>
<td class="col-lg-2"><select class="duration" name="duration" style="width:100%;"></select></td>
<td><input type="number" class=" total" min="1" name="total" style="width:50px;"></td>

<td class="col-lg-2"><select name="remarks" class="remarks" style="width:100%;"></td>
<td><a href='javascript:void(0);' class='remove'><span class='glyphicon glyphicon-remove'></span></a></td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<label>Doctor Advice</label>
<textarea name="docadvice" id="docadvice" class="form-control"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<button type="submit" class="form-control btn btn-success">Save Template</button>
<input type="hidden" name="doc_id" value="{{Auth::user()->doc_id}}">
</div>
</div>
</div>

</form>


Here is my jquery codes:



$('#addMore').on('click', function() {
$(".meditype").select2('destroy');
$(".medicine").select2('destroy');
$(".remarks").select2('destroy');
$(".duration").select2('destroy');
$(".dosage").select2('destroy');
var data = $("#tb tr").last().clone(true).appendTo("#tb");
data.find("input").val('');
data.find("select").val('');


I am a noob in controller code. so how can i get values of my all elements of form in controller . including those are dynamically created using jquery. i tried many times but only get null value or just value of first row. in jquery i initialize my select2 elements on form loading and also reinitialize them after cloning. so its working fine while i clone it. It may work for others because I search for this but not found on internet. But now getting values of this form in controller became headache for me. Trying from last 3 days but not working.
UPDATE
Here is Codes I am trying just for checking:



 $count=count($request->get('medicine'));
$temppris->medicines=$count;
$medicine=$request->get('medicine');
foreach($medicine as $index => $value)
{
$tempmedicine=new tempmedicine;
$tempmedicine->medicine_dosage=$medicine[$index]=>$value;
$tempmedicine->save();
}









share|improve this question

























  • if anyone have any solution. but need more view of codes please ask her. thanks if you help..

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:13











  • Can you post the controller code you are trying?

    – F.Igor
    Nov 24 '18 at 8:17











  • here is codes i trying.

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:51











  • i Updates codes i am trying just to check . can you suggest where am i wrong??

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:55














0












0








0


1






I have created a form in view file of my laravel 5.4 app where i can add more input fields using jquery clone() function. in this form i also use jquery select2 plugin.
Here is form:



<form name="tempform" action="{{route('temppris.store')}}" method="POST">
{{csrf_field()}}
<table class="table table-hover small-text" id="tb">
<tr class="tr-header">
<th >Sl.No.</th>
<th class="col-lg-2" >Type</th>
<th class="col-lg-3">Medicine Name</th>
<th colspan="2" class="col-lg-2">Dosage</th>
<th colspan="2" class="col-lg-2">Duration</th>
<th>Total Qty</th>
<th class="col-lg-1"> Remarks</th>
<th><a href="javascript:void(0);" style="font-size:18px;" id="addMore" title="Add More Person"><span class="glyphicon glyphicon-plus"></span></a></th>
<tr>
<td><input type="text" name="slno" style="width:100%;" readonly></td>
<td ><select name="meditype" class="meditype" style="width:100%;"></select> </td> </td>
<td class="col-lg-4"><select name="medicine" class="medicine" style="width:100%;"></select></td>
<td><input type="number" value="1" class="dos input-sm" style="width:40px;" min="1" name="dos" step="0.1"></td>
<td class="col-lg-2"><select class="dosage" style="width:100%;" name="dosage" ></select></td>

<td><input type="number" value="1" class="NoOfDuration input-sm" style="width:40px;" min="1" name="NoOfDuration" min="1"></td>
<td class="col-lg-2"><select class="duration" name="duration" style="width:100%;"></select></td>
<td><input type="number" class=" total" min="1" name="total" style="width:50px;"></td>

<td class="col-lg-2"><select name="remarks" class="remarks" style="width:100%;"></td>
<td><a href='javascript:void(0);' class='remove'><span class='glyphicon glyphicon-remove'></span></a></td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<label>Doctor Advice</label>
<textarea name="docadvice" id="docadvice" class="form-control"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<button type="submit" class="form-control btn btn-success">Save Template</button>
<input type="hidden" name="doc_id" value="{{Auth::user()->doc_id}}">
</div>
</div>
</div>

</form>


Here is my jquery codes:



$('#addMore').on('click', function() {
$(".meditype").select2('destroy');
$(".medicine").select2('destroy');
$(".remarks").select2('destroy');
$(".duration").select2('destroy');
$(".dosage").select2('destroy');
var data = $("#tb tr").last().clone(true).appendTo("#tb");
data.find("input").val('');
data.find("select").val('');


I am a noob in controller code. so how can i get values of my all elements of form in controller . including those are dynamically created using jquery. i tried many times but only get null value or just value of first row. in jquery i initialize my select2 elements on form loading and also reinitialize them after cloning. so its working fine while i clone it. It may work for others because I search for this but not found on internet. But now getting values of this form in controller became headache for me. Trying from last 3 days but not working.
UPDATE
Here is Codes I am trying just for checking:



 $count=count($request->get('medicine'));
$temppris->medicines=$count;
$medicine=$request->get('medicine');
foreach($medicine as $index => $value)
{
$tempmedicine=new tempmedicine;
$tempmedicine->medicine_dosage=$medicine[$index]=>$value;
$tempmedicine->save();
}









share|improve this question
















I have created a form in view file of my laravel 5.4 app where i can add more input fields using jquery clone() function. in this form i also use jquery select2 plugin.
Here is form:



<form name="tempform" action="{{route('temppris.store')}}" method="POST">
{{csrf_field()}}
<table class="table table-hover small-text" id="tb">
<tr class="tr-header">
<th >Sl.No.</th>
<th class="col-lg-2" >Type</th>
<th class="col-lg-3">Medicine Name</th>
<th colspan="2" class="col-lg-2">Dosage</th>
<th colspan="2" class="col-lg-2">Duration</th>
<th>Total Qty</th>
<th class="col-lg-1"> Remarks</th>
<th><a href="javascript:void(0);" style="font-size:18px;" id="addMore" title="Add More Person"><span class="glyphicon glyphicon-plus"></span></a></th>
<tr>
<td><input type="text" name="slno" style="width:100%;" readonly></td>
<td ><select name="meditype" class="meditype" style="width:100%;"></select> </td> </td>
<td class="col-lg-4"><select name="medicine" class="medicine" style="width:100%;"></select></td>
<td><input type="number" value="1" class="dos input-sm" style="width:40px;" min="1" name="dos" step="0.1"></td>
<td class="col-lg-2"><select class="dosage" style="width:100%;" name="dosage" ></select></td>

<td><input type="number" value="1" class="NoOfDuration input-sm" style="width:40px;" min="1" name="NoOfDuration" min="1"></td>
<td class="col-lg-2"><select class="duration" name="duration" style="width:100%;"></select></td>
<td><input type="number" class=" total" min="1" name="total" style="width:50px;"></td>

<td class="col-lg-2"><select name="remarks" class="remarks" style="width:100%;"></td>
<td><a href='javascript:void(0);' class='remove'><span class='glyphicon glyphicon-remove'></span></a></td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<label>Doctor Advice</label>
<textarea name="docadvice" id="docadvice" class="form-control"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-lg-12 col-md-12">
<div class="form-group">
<button type="submit" class="form-control btn btn-success">Save Template</button>
<input type="hidden" name="doc_id" value="{{Auth::user()->doc_id}}">
</div>
</div>
</div>

</form>


Here is my jquery codes:



$('#addMore').on('click', function() {
$(".meditype").select2('destroy');
$(".medicine").select2('destroy');
$(".remarks").select2('destroy');
$(".duration").select2('destroy');
$(".dosage").select2('destroy');
var data = $("#tb tr").last().clone(true).appendTo("#tb");
data.find("input").val('');
data.find("select").val('');


I am a noob in controller code. so how can i get values of my all elements of form in controller . including those are dynamically created using jquery. i tried many times but only get null value or just value of first row. in jquery i initialize my select2 elements on form loading and also reinitialize them after cloning. so its working fine while i clone it. It may work for others because I search for this but not found on internet. But now getting values of this form in controller became headache for me. Trying from last 3 days but not working.
UPDATE
Here is Codes I am trying just for checking:



 $count=count($request->get('medicine'));
$temppris->medicines=$count;
$medicine=$request->get('medicine');
foreach($medicine as $index => $value)
{
$tempmedicine=new tempmedicine;
$tempmedicine->medicine_dosage=$medicine[$index]=>$value;
$tempmedicine->save();
}






php jquery laravel controller






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 11:47









Pedro Massango

727113




727113










asked Nov 24 '18 at 8:11









fintechsoftSolution delhifintechsoftSolution delhi

11




11













  • if anyone have any solution. but need more view of codes please ask her. thanks if you help..

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:13











  • Can you post the controller code you are trying?

    – F.Igor
    Nov 24 '18 at 8:17











  • here is codes i trying.

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:51











  • i Updates codes i am trying just to check . can you suggest where am i wrong??

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:55



















  • if anyone have any solution. but need more view of codes please ask her. thanks if you help..

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:13











  • Can you post the controller code you are trying?

    – F.Igor
    Nov 24 '18 at 8:17











  • here is codes i trying.

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:51











  • i Updates codes i am trying just to check . can you suggest where am i wrong??

    – fintechsoftSolution delhi
    Nov 24 '18 at 8:55

















if anyone have any solution. but need more view of codes please ask her. thanks if you help..

– fintechsoftSolution delhi
Nov 24 '18 at 8:13





if anyone have any solution. but need more view of codes please ask her. thanks if you help..

– fintechsoftSolution delhi
Nov 24 '18 at 8:13













Can you post the controller code you are trying?

– F.Igor
Nov 24 '18 at 8:17





Can you post the controller code you are trying?

– F.Igor
Nov 24 '18 at 8:17













here is codes i trying.

– fintechsoftSolution delhi
Nov 24 '18 at 8:51





here is codes i trying.

– fintechsoftSolution delhi
Nov 24 '18 at 8:51













i Updates codes i am trying just to check . can you suggest where am i wrong??

– fintechsoftSolution delhi
Nov 24 '18 at 8:55





i Updates codes i am trying just to check . can you suggest where am i wrong??

– fintechsoftSolution delhi
Nov 24 '18 at 8:55












4 Answers
4






active

oldest

votes


















0














first make dd function inside the store function as dd($request->medicine);



please post the result then i will tell you what is the reason






share|improve this answer
























  • this is your given function returning array:1 [▼ 0 => "2" ]

    – fintechsoftSolution delhi
    Nov 24 '18 at 10:26





















0














Thanks for the reply try adding the medicines in the cloned from element and use the same dd($request->medicine); method if you get all the values inside array its working perfectly but if you are getting only the values of the original div element its definitely its naming problem



please post you result as follows by populating array so that i can view



for Example

array:2 [▼
0 => "2"
1 => "3"
]





share|improve this answer
























  • i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

    – fintechsoftSolution delhi
    Nov 24 '18 at 11:08











  • It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

    – Akhtar Munir
    Nov 24 '18 at 13:04











  • i tried to use but in dd($request) it showing on 1 element in array.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:35



















0














have you tried this



 $medicine=$request->get('medicine');
foreach($medicine as $index => $value)
{
$data = $value['medicine']; //here name will be your stored medicine name
print_r($data);
exit();
}





share|improve this answer
























  • yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:52



















0














i figure out this friends. its just a silly mistake of placing my <form> tag and closing it before closing of div that i have in my form. in browser console showing warning error of unmatched tags but i just ignoring it. wasted 3 days to this silly mistake. you should all check such warning every time using form. i just place my form tag at the starting of my div in which i makin my tag..hope this will help others..






share|improve this answer























    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%2f53456373%2fnot-getting-data-in-laravel-5-4-controller-of-dynamically-created-array-of-form%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    first make dd function inside the store function as dd($request->medicine);



    please post the result then i will tell you what is the reason






    share|improve this answer
























    • this is your given function returning array:1 [▼ 0 => "2" ]

      – fintechsoftSolution delhi
      Nov 24 '18 at 10:26


















    0














    first make dd function inside the store function as dd($request->medicine);



    please post the result then i will tell you what is the reason






    share|improve this answer
























    • this is your given function returning array:1 [▼ 0 => "2" ]

      – fintechsoftSolution delhi
      Nov 24 '18 at 10:26
















    0












    0








    0







    first make dd function inside the store function as dd($request->medicine);



    please post the result then i will tell you what is the reason






    share|improve this answer













    first make dd function inside the store function as dd($request->medicine);



    please post the result then i will tell you what is the reason







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 24 '18 at 9:51









    Manojkiran.AManojkiran.A

    31228




    31228













    • this is your given function returning array:1 [▼ 0 => "2" ]

      – fintechsoftSolution delhi
      Nov 24 '18 at 10:26





















    • this is your given function returning array:1 [▼ 0 => "2" ]

      – fintechsoftSolution delhi
      Nov 24 '18 at 10:26



















    this is your given function returning array:1 [▼ 0 => "2" ]

    – fintechsoftSolution delhi
    Nov 24 '18 at 10:26







    this is your given function returning array:1 [▼ 0 => "2" ]

    – fintechsoftSolution delhi
    Nov 24 '18 at 10:26















    0














    Thanks for the reply try adding the medicines in the cloned from element and use the same dd($request->medicine); method if you get all the values inside array its working perfectly but if you are getting only the values of the original div element its definitely its naming problem



    please post you result as follows by populating array so that i can view



    for Example

    array:2 [▼
    0 => "2"
    1 => "3"
    ]





    share|improve this answer
























    • i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

      – fintechsoftSolution delhi
      Nov 24 '18 at 11:08











    • It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

      – Akhtar Munir
      Nov 24 '18 at 13:04











    • i tried to use but in dd($request) it showing on 1 element in array.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:35
















    0














    Thanks for the reply try adding the medicines in the cloned from element and use the same dd($request->medicine); method if you get all the values inside array its working perfectly but if you are getting only the values of the original div element its definitely its naming problem



    please post you result as follows by populating array so that i can view



    for Example

    array:2 [▼
    0 => "2"
    1 => "3"
    ]





    share|improve this answer
























    • i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

      – fintechsoftSolution delhi
      Nov 24 '18 at 11:08











    • It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

      – Akhtar Munir
      Nov 24 '18 at 13:04











    • i tried to use but in dd($request) it showing on 1 element in array.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:35














    0












    0








    0







    Thanks for the reply try adding the medicines in the cloned from element and use the same dd($request->medicine); method if you get all the values inside array its working perfectly but if you are getting only the values of the original div element its definitely its naming problem



    please post you result as follows by populating array so that i can view



    for Example

    array:2 [▼
    0 => "2"
    1 => "3"
    ]





    share|improve this answer













    Thanks for the reply try adding the medicines in the cloned from element and use the same dd($request->medicine); method if you get all the values inside array its working perfectly but if you are getting only the values of the original div element its definitely its naming problem



    please post you result as follows by populating array so that i can view



    for Example

    array:2 [▼
    0 => "2"
    1 => "3"
    ]






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 24 '18 at 10:57









    Manojkiran.AManojkiran.A

    31228




    31228













    • i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

      – fintechsoftSolution delhi
      Nov 24 '18 at 11:08











    • It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

      – Akhtar Munir
      Nov 24 '18 at 13:04











    • i tried to use but in dd($request) it showing on 1 element in array.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:35



















    • i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

      – fintechsoftSolution delhi
      Nov 24 '18 at 11:08











    • It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

      – Akhtar Munir
      Nov 24 '18 at 13:04











    • i tried to use but in dd($request) it showing on 1 element in array.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:35

















    i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

    – fintechsoftSolution delhi
    Nov 24 '18 at 11:08





    i tried it but when i checking value of medicine in jquery it giving all values see here, function checkit() { $('select[name="medicine"]').each(function(){ alert($(this).val()); }); } but when i trying to get it in controller after submitting it. its giving only first original select value.

    – fintechsoftSolution delhi
    Nov 24 '18 at 11:08













    It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

    – Akhtar Munir
    Nov 24 '18 at 13:04





    It means you are returning array from your jquery so you should use foreach() function in your controller to make it's seperated values and then submit it.

    – Akhtar Munir
    Nov 24 '18 at 13:04













    i tried to use but in dd($request) it showing on 1 element in array.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:35





    i tried to use but in dd($request) it showing on 1 element in array.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:35











    0














    have you tried this



     $medicine=$request->get('medicine');
    foreach($medicine as $index => $value)
    {
    $data = $value['medicine']; //here name will be your stored medicine name
    print_r($data);
    exit();
    }





    share|improve this answer
























    • yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:52
















    0














    have you tried this



     $medicine=$request->get('medicine');
    foreach($medicine as $index => $value)
    {
    $data = $value['medicine']; //here name will be your stored medicine name
    print_r($data);
    exit();
    }





    share|improve this answer
























    • yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:52














    0












    0








    0







    have you tried this



     $medicine=$request->get('medicine');
    foreach($medicine as $index => $value)
    {
    $data = $value['medicine']; //here name will be your stored medicine name
    print_r($data);
    exit();
    }





    share|improve this answer













    have you tried this



     $medicine=$request->get('medicine');
    foreach($medicine as $index => $value)
    {
    $data = $value['medicine']; //here name will be your stored medicine name
    print_r($data);
    exit();
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 24 '18 at 13:20









    Akhtar MunirAkhtar Munir

    6611




    6611













    • yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:52



















    • yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

      – fintechsoftSolution delhi
      Nov 25 '18 at 10:52

















    yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:52





    yes, i tried this and using dd($request->all()); it showing just one item in array. thats why i can't figure out problems in code.

    – fintechsoftSolution delhi
    Nov 25 '18 at 10:52











    0














    i figure out this friends. its just a silly mistake of placing my <form> tag and closing it before closing of div that i have in my form. in browser console showing warning error of unmatched tags but i just ignoring it. wasted 3 days to this silly mistake. you should all check such warning every time using form. i just place my form tag at the starting of my div in which i makin my tag..hope this will help others..






    share|improve this answer




























      0














      i figure out this friends. its just a silly mistake of placing my <form> tag and closing it before closing of div that i have in my form. in browser console showing warning error of unmatched tags but i just ignoring it. wasted 3 days to this silly mistake. you should all check such warning every time using form. i just place my form tag at the starting of my div in which i makin my tag..hope this will help others..






      share|improve this answer


























        0












        0








        0







        i figure out this friends. its just a silly mistake of placing my <form> tag and closing it before closing of div that i have in my form. in browser console showing warning error of unmatched tags but i just ignoring it. wasted 3 days to this silly mistake. you should all check such warning every time using form. i just place my form tag at the starting of my div in which i makin my tag..hope this will help others..






        share|improve this answer













        i figure out this friends. its just a silly mistake of placing my <form> tag and closing it before closing of div that i have in my form. in browser console showing warning error of unmatched tags but i just ignoring it. wasted 3 days to this silly mistake. you should all check such warning every time using form. i just place my form tag at the starting of my div in which i makin my tag..hope this will help others..







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 25 '18 at 17:45









        fintechsoftSolution delhifintechsoftSolution delhi

        11




        11






























            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%2f53456373%2fnot-getting-data-in-laravel-5-4-controller-of-dynamically-created-array-of-form%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

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks