Reputation: 21
Let's say I have two database tables: Panels and Collection.
I'm trying to add/edit rows in each table using forms. They both have similar fields such as name and price, but they also have fields that are unique.
Using JQuery, how can I consolidate the inputs in one form and only show the inputs that correspond to the table chosen where the row is to be added or edited?
<input name="name"></input>
<input name="price"></input
<input name="per_door_price"></input> <!--corresponds only to panel table-->
<input name="series"></input> <!--corresponds only to collection table-->
The table would be chosen in another page and sent to the form using $_POST.
Upvotes: 0
Views: 65
Reputation: 55740
Use the this
context or find
method
$('#tables').find('input')
or
$('input', '#tables')
This will only target the input elements inside the table with id="tables"
Upvotes: 1