I have a form that contains 1 select option and 5 text fields.
My first function is when I select a specific option, those 5 text fields will auto-populate data from the database. This function is specific to the ID of the selected option.
And I have another function that when I click the "Add another" button, it will clone the form and will generate a new ID for each text fields.
The problem is, when I click the add another and the second form is there, the 5 text fields doesn't auto-populate because the auto-populate function is specific only to the original ID.
How do I solve this? How do I apply the auto-populate function to the newly generated form? Please help.
Given the form:
<form method='post' name="form1">
<select id='select'>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
First Name: <input type='text' id='fname'>
Last Name: <input type='text' id='lname'>
Contact Number: <input type='text' id='cnumber'>
Address: <input type='text' id='address'>
E-mail Address: <input type='text' id='email'>
<button type='button' id='addanother'>Add Another</button>
</form>
Thank you!