473,779 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1959
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********@vir gin.net> wrote in message
news:0X******** **********@news fe6-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
2863
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 2nd order lists that appear to the right when hovering over items in the 1st order. Anyone figured how to modify to go to n order greater than 2? Bit tricky I found. I could get the other orders but they all appeared when hovering over the 1st...
18
2193
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. Question: Does google interpret javascript? Or, in other words, are client-side-javascript-generated links invisible to search engines?
3
2129
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 menu options are displayed thanks a lot -- AdamPC@hotmail.com
2
1374
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 event name"> When users selects an item, it will do a postback to server. Before the postback completes and the page refreshes, click any dropdown menu again (either dropA or dropB) the frame page will become blank out. I must to click F5 or refresh...
4
2347
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 list/menu appears. When the page is opened in the browser (as it appears by default), the dropdown menu positions are correctly displayed. But when I scroll the page and then move the mouse over any menu item of the navbar, the dropdown menu is not...
1
2175
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 selects an category from the first dropdown menu 2, if the category has subcategories then dynamically create a new dropdown underneath and in the process fill it with the subcategories from the chosen option in the first menu. 3, keep doing the above...
1
2005
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 while, and can't figure out why I can't set the dropdown menus to appear above other elements which also have dropdown menus. I run multiple suckerfish menus on the page, but these somewhat complex ones are the only ones which have issues. I...
4
2126
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. When I open the same database in Office 2002, the dropdown boxes have populated menus. Now I have converted the database to 2002 format and it still works fine when opening in 2002, but still have the same problem when opening in 2003. Has anyone...
19
3695
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 code for this from a tutorial but that menu was flush-left justified. Not what I want. Subsequent searches on google on how to center yielded a
0
9636
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10306
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.