473,397 Members | 1,950 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,397 software developers and data experts.

Dropdown menus problem

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 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, or can direct me to a
suitable link?

Thanks
Ian
Nov 12 '05 #1
4 1933
Ian Davies wrote:
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 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, or can direct me to a
suitable link?

Thanks
Ian

If I understand you correctly this is not a problem for php. You want
javascript. PHP only works when you open the page because it is a server
side language.
Nov 12 '05 #2

"Ian Davies" <ia********@virgin.net> wrote in message
news:0X******************@newsfe6-win.ntli.net...
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 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, or can direct me to a
suitable link?

Thanks
Ian


There are two things you need to do and actually two different ways.

1. Do them all on client side using Javascript. add event handler for the
first select to handle onChange event.

2. Do it partly on client side and send it back to server on the event
"onChange". and re-build the second select options with values based on what
is sent back from options of the first select.

Shwn
Nov 22 '05 #3
Ian Davies wrote:
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 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, or can direct me to a
suitable link?

Thanks
Ian

It would be possible to do this with PHP by submitting the page back to
itself and load the second menu depending on your $_POST value.
The downside is that you would be reloading the complete page each time
the first drop down menu is selected. If you have a fast page it may not
even be a problem.
Nov 22 '05 #4
Take a look at PEAR's HTML/QuickForm
they have something that looks like this.

Nov 22 '05 #5

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

Similar topics

19
by: chart43 | last post by:
I have question about the technique for css dropdown menus described in http://www.alistapart.com/articles/horizdropdowns/. Based on an html list, it has a few items in a 1st order list and further...
18
by: sandy | last post by:
This sounds like a frequently asked question, but I didn't find the answer in any faq I've looked at. I have a question about the wisdom of using (javascript generated) dropdown menus. ...
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...
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...
4
torquehero
by: torquehero | last post by:
Hi all :) I have created a horizontal navbar using Xara Menumaker. The Menu items have several dropdown menus. Its a javascript. When the mouse cursor is moved over any menu item, a dropdown...
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...
1
by: pedalpete | last post by:
Hey Gang, More difficult to describe this than see it, so here's a link which shows the issue I'm having http://zifimusic.com/testing/broken-hovers.html I've been looking at this for quite a...
4
by: bloukopkoggelmander | last post by:
Hello all A strange problem here. We have an Access 2000 database in use. I upgraded one user to Office 2003 SP3. When he now open this database, all dropdown boxes are displaying blank menus....
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...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.