troubleshooting Question

How to select which input field is related to a button with Ajax form

Avatar of Richard Lloyd
Richard Lloyd asked on
AJAX
4 Comments1 Solution13 ViewsLast Modified:
I have a shopping cart that displays a grid of products on a single page. Each product has an input number field to capture the quantity required and an "Add to cart"/ "Update cart" button.

The input number fields each have a class of "product_qty" and an id of "qty_x" and where X is the unique id of the product. The add/update buttons have id "btn_x" and class of "update_cart".

Please can any advise how I can make sure I pass the correct value from the product quantity input to my Ajax form when I click the "Add to cart" button on a particular product.

I sort of need to "link" the input field to the button on each product, in a traditional form, the input and button would be contained within a <form></form>, but I am not sure how to do this in Ajax.

Thank you
ASKER CERTIFIED SOLUTION
leakim971
Multitechnician
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros