Jump to content

Drop Down menu with script


EnzoDerek

Recommended Posts

Hello there,I'm am 12 years old and and a web page designer. I really need this to finish this client's website I have. I'm looking how to create a changing drop down menu. Kindof like the ones you might see in checking out from buying from a website. For Example:Click Your Country:United StatesCanadaIf the user selects United States, all the states would be the same. Same thing with selecting Canada.Thanks,Derek

Link to comment
Share on other sites

You'd have to use arrays. :)I can show you how to make it, but I wont make it completely for you.First, learn how to insert options into a select box, with createElement() and appendChild(). Look them up on a dom reference, or the Mozilla Dom Docs.Next, make 2 arrays. In the first one, put all of the US states. In the second one, all of the canadian provinces.Loop through the arrays. Check what option is selected in the select box. If it's United States, then loop through the arrays and keep apending a new option with the value of the array[loop] value. Congrats. :)But wait---are you at least slightly experienced in javascript? You wont have a clue what I'm saying unless you know java/C...Which I doubt. :)

Link to comment
Share on other sites

You'd have to use arrays. :)I can show you how to make it, but I wont make it completely for you.First, learn how to insert options into a select box, with createElement() and appendChild(). Look them up on a dom reference, or the Mozilla Dom Docs.Next, make 2 arrays. In the first one, put all of the US states. In the second one, all of the canadian provinces.Loop through the arrays. Check what option is selected in the select box. If it's United States, then loop through the arrays and keep apending a new option with the value of the array[loop] value. Congrats. :)But wait---are you at least slightly experienced in javascript? You wont have a clue what I'm saying unless you know java/C...Which I doubt. :)
Are you trying to offend me or something???
Link to comment
Share on other sites

No, I'm sorry you think that--I was trying to ask whether or not you know java/c/javascript, otherwise you wouldn't really understand what I'm trying to say. Please don't take offense.

Link to comment
Share on other sites

No, I'm sorry you think that--I was trying to ask whether or not you know java/c/javascript, otherwise you wouldn't really understand what I'm trying to say. Please don't take offense.
Ok, you just said it in an offensive tone. All clear :) Yes I know JavaScript, I know what you mean. Thank you very much! :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...