473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

dropdown menu problem

Hello
Ive been informed that I need to do the following in javascript.
I have two drop down menus in my php script. The items displayed in the
second is dependent on which item is choosen from the first i.e. the choosen
item from the first filters the items in the second

first dropdown menu
sub no sub
1 science >>>>>>>>> if this is selected
2 maths
3 something else
second dropdown menu
TopicNo sub no TopicDesc
1 1 Science Topic1 >>>>>>>>>>>>>>>> displayed
2 2 Maths topic 1
3 3 Something else Topic1
4 1 Science topic 2>>>>>>>>>>>>>>>> displayed
5 2 Maths Topic 2
6 3 Something else topic 2

all others not displayed

The problem is this only works once when I open the page (with the default
values).
I would like to get the second dropdown box to update as soon as an Item is
selected from the first. I have searched the net but cannot find anything.
It seems that this is something that is not commonly done. The data for
populating the lists comes from a mysql database.

Does anyone know of a script to do this with php and/or Java, or can direct
me to a
suitable link?

Thanks
Ian

Nov 23 '05 #1
2 1592
Ian Davies wrote:
Hello
Ive been informed that I need to do the following in javascript.
I have two drop down menus in my php script. The items displayed in the
second is dependent on which item is choosen from the first i.e. the choosen
item from the first filters the items in the second
[...]
The problem is this only works once when I open the page (with the default
values).
Without showning what you have attempted no one can tell you where it is
going wrong.

I would like to get the second dropdown box to update as soon as an Item is
selected from the first. I have searched the net but cannot find anything.
There are thousands upon thousands of such scripts... Google 'dynamic
menu list' or 'dynamic option list'.

It seems that this is something that is not commonly done.


It is very common and can be done purely in CSS:

<URL:http://www.howtocreate.co.uk/tutorials/testMenu.html>
or in javascript:

<URL:http://www.litotes.demon.co.uk/example_scripts/>


--
Rob
Nov 23 '05 #2
Ian Davies wrote:
I would like to get the second dropdown box to update as soon as an
Item is selected from the first.
I have searched the net but cannot
find anything. It seems that this is something that is not commonly
done.
You may not searched on the right keywords, because solutions for this are
all over the web, and it is a quite common thing to be done.
For example,
http://www.JavascriptToolbox.com/dynamicoptionlist/
The problem is this only works once when I open the page (with the
default values).


This leads me to believe that you're firing a sql query to get the values
for the second list for only the value that is in the first list.
You have a couple of options:

1) You can fire the query every time the first box changes and populate the
second box. This will either require an ajax-like technique, or reloading
the page.

2) You can query for all possibilities when building the page, and code all
possible variations into pure javascript which will populate the second box
immediately on change of the first. This is the technique used in my url
above.

Which solution you pick depends a lot on your environment, browser support,
degradation requirements, and experience.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ian Davies | last post by:
Hello I have two drop down menus in my php script. The items displayed in the second is dependent on which item is choosen from the first i.e. the choosen item from the first filters the items in...
3
by: ACaunter | last post by:
Hi there, can someone please tell me what the easiest way to have a dropdown menu bar positioned on the screen (eg. Home, company, ... , contact us) then when the mouse goes over then, the sub...
1
by: GatorBait | last post by:
Hi all, I'm using the new ToolStrip control in a project and I'm running into a problem that I'm hoping someone can help me with. I am building the toolstrip in code by adding buttons,...
2
by: t3rm1ght | last post by:
Hello everyone, I was having a strange issue with tooltips on a dropdown menu, Im using VB.NET 2005 Express Beta 2, I have a friend who has the C# IDE and had the exact same problem. Anywho, I...
2
by: Brian | last post by:
Hi, All, I have two dropdown lists in itemtemplate in a datagrid. for example, dropA and dropB. also, for the dropdown, I set < Runat="server" AutoPostBack="True" OnSelectedIndexChanged="some...
2
by: William Youngman | last post by:
We are developing an application that presents data to the user in a gridview and we are using the dropdown extender to give the user a SharePoint 2007 type dropdown menu attached to the cells of a...
1
by: redgoals | last post by:
Hi, I have searched the forum for a similar problem but have been unable to find anything. What i am trying to achieve is a dropdown menu which behaves in the following way: 1, Someone...
19
by: Jim | last post by:
Hi, I have two questions/problems pertaining to CSS horizontal dropdown menus and am hoping that someone here can help me out. (1) I'm having a problem centering the menu. I picked up the...
1
by: paulyXvpf | last post by:
Hello javascript folks, PROBLEM: Javascript dropdown problem in IE 6 and IE7 DESCRIPTION: menu falls behind a container box on web page COMMENTS: It works fine in Firefox but not in IE 6/7...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.