mardi 2 octobre 2018

Form posting input values updated in jquery to a controller in laravel

Currently I'm working on a laravel form and I have to pass some values to a database. I'm doing this through the traditional way of getting my values and sending them via request in my controller.

In my form I have some drop downs that are populated by an ajax request via jquery. My ajax request updates the values in the drop down and they are visible to the user to select.

Here is one of the lis

<li value="25" data-cost="94.00"><span>25</span></li>

Once the li is selected to pass the data to laravel I have jquery create a hidden input.

<input type="hidden" name="quantity" value="50">

Then in my laravel controller I do this:

$productOrderDetails->quantity = $request->input('quantity');

My expected behavior is for my controller to receive the "value" of whatever the input field is. However I get null no value is passed over.
I suspect it would be because the input is created in the DOM by jquery but wouldn't this be the same as a user typing something into an input box? I realize there is client side and server side based upon the responses to some similar questions. Any direction would be appreciated, thank you!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire