The values of the input fields are not changing. When I alert the variables I get values from the MySQLI database, so there can't be a problem with my php script. Moreover, I've swapped the value() to a css colour and indeed the input fields are all being coloured. So I'm a little confused why it just isn't changing the value to the value of the variables???
Please note the option which triggers the event is one of the options in the drop down menu; that's why I've got to come up tor DOM and then across and it's quite longwinded. I'm new to Jquery btw, so if this can be done in a better way I'll be pleased to hear.
If the HTML is helpful, I've added it below as well
Thank you in advance.
Jquery
$('.option').on('click', function(){
var name = $(this).html();
$.post('ajax.php', {name: name}, function(data) {
var obj = jQuery.parseJSON(data);
var item = obj[6]
var desc = obj[7]
var qty = obj[8]
var price = obj[9]
var disc = obj[10]
var account = obj[11]
var tax = obj[12]
var amount = obj[13]
$(this).closest("td").siblings().eq(0).children().val(item);
$(this).closest("td").siblings().eq(1).children().val(desc);
$(this).closest("td").siblings().eq(2).children().val(qty);
$(this).closest("td").siblings().eq(3).children().val(price);
$(this).closest("td").siblings().eq(4).children().val(disc);
$(this).closest("td").siblings().eq(5).children().val(account);
$(this).closest("td").siblings().eq(7).children().val(tax);
$(this).closest("td").siblings().eq(9).children().val(amount);
});
});
HTML Sample
<td>
<input type="text" name = "sales[1][item]" size = "12">
</td>
<td>
<button class="item" type = "button">Add</button>
<div class = "dropmenu"></div>
</td>
<td>
<input type="text" name="sales[1][description]" size="40">
</td>