In jQuery, how to get multiple dropdowns for each group of handset, for example:
Customer can select more than 1 handset to make an order. Firstly customer will need to select a number of handset from a dropdown (1 to 15).
If they have selected number 5 from a dropdown then 5 groups of dropdrowns should appear like this:
Group One:
Select Phone [Dropdown / load entries via ajax]
Select Contract Length [Dropdown / load entries via ajax]
Select Contract Plan [Dropdown / load entries via ajax]
Select Additional Addon [Dropdown / load entries via ajax]
Group Two:
Same dropdowns as above
Other question is, if there an error (validation from PHP) for not filling the form properly – it will redirect back same page but the dropdowns will need to be reselected again. How to make that to work also?
Pretty sure you will have to bring some variable indicating the failure of form completion like into a session or some hidden element in html and then on document load – check for that variable and manually invoke those drop downs.
OR
Do not allow to click the submit button and check the validation in javascript. However it won’t be that secure but it would save hassle for both you and the user. I myself would prefer form being checked before clicking submit just to wait a few seconds until the page is reloaded and I face the fact I chose/wrote something wrong.
OR
Validate automatically with xmlhttprequest or something similarly working so on submit click, js accesses php file, validates, returns the result and allows submission of data. Won’t be super secure but… You can recheck that with the same php file again (will be caught if someone tried illegitimately pass some data not through form and xmlhttprequest failed to catch it). Would be safest and nicest way for the user.