The entire table is quite large for posting but here are more details:
I have a number of rows which take personal name and address details: name, address1, address2, town, country.
I also need to take the user’s billing name and address.
What I want to do is just present one set of rows and offer the user a checkbox saying “Are your billing details the same as your personal details?” As this is the case 99% of the time, the checkbox is checked by default. If the user UNchecks it, I’d like another set of rows to appear (all with the same labels… name, address1, address 2, etc., for him/her to fill in with these different details.
I could (as some types do) just put both sets of rows on the page with the checkbox and expect the user to just ignore the billing set if they ARE the same. It just grates on me slightly: messy. If the rows are not required, I’d rather not show them.
To test: literally just work with this…
Name:
Address1:
Billing same...?
OK? Three rows here. Would like to repeat the first two (minus content) if user unchecks checkbox. Or feel free, if you have a better way, to suggest but please remember my JS is embryonic.
Hi @mike324, that sounds like you’d actually want to display a form after the table with the personal details, not another table. Anyway the general approach would be adding an event listener to the checkbox to toggle the hidden state of the billing details:
The rows for personal details are a table within a form (they need entering too). Would have been cleaner with CSS instead of table but I know I could add/delete table rows with JS so went the table for layout route. But yes, just hiding it rather than generating it… simple but strong idea.