Dynamically Added Form Fields
Posted: Tue Mar 25, 2003 11:23 pm
I have seen some forms which dynamically add fields as needed based on user input.
For example, a question (e.g. list box) might ask: "Do you smoke?"
If the user selects "No", the form does not change. However, if the user selects "Yes" (from the listbox), the form automatically inserts a new row into the form with a new question and listbox field:
"What do you smoke?"
The user can then select an entry from the new listbox: "tobacco", "marijuana", or "crack".
This strategy allows a form to stay as small as possible by omitting entry fields unless they are necessary.
Question 1: Where could I find PHP code that would do this or what approach would you recommend?
(I want the new row to be inserted via PHP into the HTML - not just "hiding" in the existing html.)
Question 2: Does this data entry method have a name?
For example, a question (e.g. list box) might ask: "Do you smoke?"
If the user selects "No", the form does not change. However, if the user selects "Yes" (from the listbox), the form automatically inserts a new row into the form with a new question and listbox field:
"What do you smoke?"
The user can then select an entry from the new listbox: "tobacco", "marijuana", or "crack".
This strategy allows a form to stay as small as possible by omitting entry fields unless they are necessary.
Question 1: Where could I find PHP code that would do this or what approach would you recommend?
(I want the new row to be inserted via PHP into the HTML - not just "hiding" in the existing html.)
Question 2: Does this data entry method have a name?