1
fly2moon2
Newbie question on dynamically creating dropdown lists
  • 2005/9/13 6:35

  • fly2moon2

  • Just popping in

  • Posts: 9

  • Since: 2005/8/17


Hi,


I know this question has been asked before. But I'm really stuck after several attempts:

I want to have a dropdown listbox (e.g. Country), by updating of which would in turn dynamically updates the list of a 2nd dropdown list (e.g. Province). The list info all comes from the database.


I understand that this requires incorporation of Javascript codes. I have failed in previous attempts. And want to confirm the correct approach to this.

At the onChange action of Country list, what action should I use?

Possibility 1: Should I be using a form submit action? Then, upon submission, the Province list box be refreshed and retrieve data based on the Country selected? - - - here, I have problem getting the value of the posted Country box. If the name of the dropdown box is 'Country', how should I get the selected value?

Possibility 2: Should Country box's onChange action ,instead of using form submit action, fire an event to create/re-create the Province list? I don't know if this is feasible? By that, will it be using Javascript to do, instead of using PHP to create the Province list?


Would like you experts' help. Appreciate if there is some working example scripts for better understanding.

thanks a lot,
jackling

2
Pnooka
Re: Newbie question on dynamically creating dropdown lists
  • 2005/9/13 6:40

  • Pnooka

  • Just popping in

  • Posts: 68

  • Since: 2004/7/16


There's a working example of this at Pnooka.org. I could give you that code, but you have to wait until i get back from my vacation next week to get it. I forgot to mention, that the code in question is used in the registration form. It might not work for all countries, since i haven't filled in every state info for all of them, yet.

3
fly2moon2
Re: Newbie question on dynamically creating dropdown lists
  • 2005/9/13 7:31

  • fly2moon2

  • Just popping in

  • Posts: 9

  • Since: 2005/8/17


Hi Pnooka!,


Thanks for your generous sharings! Yes, really appreciate you can share your codes for reference.

Wait for your response then. Have a nice vacation!

best regards,
jackling

4
McNaz
Re: Newbie question on dynamically creating dropdown lists
  • 2005/9/13 8:15

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


Hi Fly.

I implemented something very similar in xasset..

Unfortunatly the download zip file is no longer there (lost during a hack a few months ago). You can still download the source from the CVS and have a look.

Login

Who's Online

219 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 219


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits