dynamic drop down menu

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Shamma
Forum Newbie
Posts: 6
Joined: Mon Mar 01, 2010 5:25 am

dynamic drop down menu

Post by Shamma »

hi there

I have a drop down menu which I retreive from DB. at the end of the options I added 'other'. --> when the user selects other option I want another drop down menu to be created to me and retreived data from DB as well.

how can I do that



thanks
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: dynamic drop down menu

Post by califdon »

If you have to retrieve more data from the server, you will have to use AJAX, the Javascript way to get data from the server without loading a new html page. Google for javascript ajax and you will find loads of info.
Shamma
Forum Newbie
Posts: 6
Joined: Mon Mar 01, 2010 5:25 am

Re: dynamic drop down menu

Post by Shamma »

yes I know it is not effecient and I know AJAX is better, but I can't go for ajax cause I am not using ASP.NET .. I am just using simple HTML

I need any simple code for that, I google it and there is nothing useful
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: dynamic drop down menu

Post by califdon »

Shamma wrote:yes I know it is not effecient and I know AJAX is better, but I can't go for ajax cause I am not using ASP.NET .. I am just using simple HTML

I need any simple code for that, I google it and there is nothing useful
I said nothing about being efficient or that AJAX is better than something else. AJAX also has nothing whatsoever to do with ASP.NET.

If you don't use Javascript, it is impossible to do anything based on what the user chooses in a dropdown list. HTML does nothing beyond displaying the page. AJAX is just Javascript, but it relies on there being a server-side script to respond with the required data. Server-side scripts would be PHP, Perl, or VBScript (if you are using a Microsoft web server).
Shamma
Forum Newbie
Posts: 6
Joined: Mon Mar 01, 2010 5:25 am

Re: dynamic drop down menu

Post by Shamma »

ok, I am using javascript to validate inputs and to store them in cookies. I am using a php lanuage as well

Can you give me a good example then of how to generate a dynamic drop down menu ?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: dynamic drop down menu

Post by califdon »

Here is a thorough tutorial on doing exactly what you asked about:
http://www.webmonkey.com/2010/02/build_ ... down_menu/

I am happy to provide the link to you, but for your future reference, all I did was Google ajax tutorial dropdown and pick the first result I found. If you will learn to do this, you will usually find answers to your questions much faster than in a forum like this.

Good luck with your project.
Post Reply