Skip to content
Advertisement

AJAX POST Form Always posts Data from the first record in the list

I found this issue is related to my AJAX posting method. If I post this form using the standard method (action=””) it works fine it polulates my database according to which record I select in the list to post. But when I use the AJAX Post method it will only poplulate the values with the first record on the SQL Results list. I made my input fields visible and all the posted content is unique and as expected. Below is the full code.

JavaScript

Advertisement

Answer

$(‘.name’).val()` is the value of the first element with that class. You need to select the element that’s in the same form as the button that was clicked.

JavaScript

You could also get all the form inputs with:

JavaScript

And in the callback function, you also need to update the appropriate element.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement