Multiple same name class on form, only one item need to be populated via an ajax query
I have multiple same name class on form, only one item need to be populated via an ajax query
Need to select an item in a dropdown and do a ajax query and return the price associated with that item and size in the row that was previously selected
Example:
<select class="size" id="size">
<option value="12">"500g"</option>
<option value="14">"Bag 400g-500g"</option>
</select>
Need value 14
- $('.size').change(function ()
- {
- var size = $(this).parent().parent().text(); // problem with this line of code.....
- //var size = 14; // this work if if i pass the 14
-
- $.ajax(
- {
- type: 'POST',
- url: "size.php",
- data: {size: size},
- dataType: 'JSON',
- success: function (data)
- {
- $('#prsize').val(data[0].prsize); // also problem to store in the row that was selected. Now it store the value in all of the rows.
- }
- });
- });
- .
- //This class get repeated per row. Dynamic table that gets created via a query
- <div class=\"prsize\"></div>