PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a form that I would like users to select their country. If a user selects USA, then I would like my state drop down that also includes Canada provinces to only show US states only as selectable (and vis a vis, if Canada is slected). For all other countries other than USA or Canada, I would like an open text box for entering territories instead of the State/Province drop down. Any ideas how can set this up?
FYI, the options available in my Country and State drop downs are pulled from my mysql table. Here's a sample of the code:
I provided the code for my country select which shows how it is plugged in a mysql table to generate the available options. The code for the state select is similarly structured, so no need for me to inlude that tidbit of code here(...I think). I am looking to update the functionality on my site's form that would control what select options are available in my state dropdown (select) based on selection made in the country select. For example, when a user select US then I want only US states to be available under the state drop down and same concept for Canada when it is selected as the country. I've seen it done on many a site, so I know it is not impossible or rather exotic. So that's one objective I am trying to get clues on how to implement.
The next objective is for all other countries (not US or Canada), I want the state select to instead be replaced with a open text field.
The tricky part (for me that is) is for these proposed live form changes to take place while certain selections are being made on the form (not after the submit button is activated). How do I set up a triggering mechanism code-wise that would in real time update dependent form elements in the way I explained above?