473,396 Members | 2,057 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,396 software developers and data experts.

Seeking a web tutorial on 'chained' selectors

scubak1w1
Hello,

I have a form where users select various parameters from drop down boxes to query and then get to to see the results for the their selection.

The pulldowns are populated via some constructed SQL pulling data out of a PostgreSQL database.

I would like to make the pulldowns 'interconnected' as it were - but wanted some online reading matter to help me poke at this and was hoping someone had a online tutorial they could point me at...

For instance, if they select a particular mine site (or whatever), only boreholes in the database drilled at that mine site will be then be available in the pulldowns for the boreholes.

I can get my head OK around the logic, but am having trouble with the technical steps needed - hence the needed for a "cheat" as it were - and Google has not been my friend here, if you will excuse the cliché...

I assume it would be a matter of using an 'onchange' for the <select> to trigger an adjustment of the relevant WHERE clauses of the SQL statements for other relevant pulldowns and then refresh (?) the page??

Any help in pointing me to a URL would be much appreciated!


Regards,
GREG...
Feb 26 '08 #1
6 1361
nathj
938 Expert 512MB
Hi Greg,

It's nice to see someone here not after a full code sample but wanting to learn for themselves.

You are part way there with the use of onchange for your dropdown. This onchange then needs to call some JS function that uses the XMLHTTPRequest object to define the next drop down box.

I would consider forcing the user through a series of steps. So you have 4 lists for example and each list is dependant on the choices made in the previous list.

When the page first loads only one list is available, however, underneath this are 3 empty <div>'s with unique ID's. When the user makes a selection the onchange event calls the JS that then uses a php file on the server to define the next list. This definition is then written to the innerhtml of the next empty div; enabling the user to select from the next list and so on and so forth.

This is the basic logic you need, you may need to play around with it a it but essentially I think it's what you are after.

The technology you need to achieve this is know as AJAX - Asynchronous Javascript And Xml (not a cleaning fluid or a Dutch football team).

When I first tried to get my head around this I found this tutorial really helpful.

Have a go with this and if you get stuck wioth any of post back here with your code and I'll do my best to help - I'm sure you'll have this up and running in no time at all.

Cheers
nathj
Feb 26 '08 #2
ronverdonk
4,258 Expert 4TB
I don't really have a tutorial, but googling gets you far. The following link shows a simple 'chained select' demo plus explanation. Maybe it is of any help AJAX chained select demo

Ronald
Feb 26 '08 #3
Thanks you kind sirs (?)... just need to get it the current page working in IE 6&7 - and then off to try and get my head around this...

Much appreciated!

'cause if you 'ain't learning something new, you may as well be dead... ;-)
Feb 26 '08 #4
ronverdonk
4,258 Expert 4TB
Thanks you kind sirs (?)... just need to get it the current page working in IE 6&7 - and then off to try and get my head around this...

Much appreciated!

'cause if you 'ain't learning something new, you may as well be dead... ;-)
You are welcome! See you around a next time.

Ronald
Feb 26 '08 #5
You said to post back if I got stuck...

I think I have everything in place... BUT no changes occur when I try and update the div's innerHTML with the reponsetext....

see the last post in the thread "Seeking help on why changing innerHTML..." in the Javascript / DHTML / Ajax Forum... my (buggy! :-) ) code copied there....

Cheers!
Mar 4 '08 #6
ronverdonk
4,258 Expert 4TB
Will have a look in the JS forum.

Ronald
Mar 4 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: CPK Smithies | last post by:
Just joined this group, fascinated by Python. Many thanks to those who have worked so hard on it! One big problem, though: I was completely thrown by this, which I quote from the Tutorial: >...
1
by: Tony Benham | last post by:
I have been getting to grips with css recently (very slowly), and one area I have a problem is when to use class selectors or id selectors. Are there any guidelines when to use each type ? The key...
4
by: Andy Fish | last post by:
hi, I am using descendent selectors to format cells within a table according to the css class of the table. However, when using nested tables, it seems to pick up the outer matching rule rather...
6
by: Greg M | last post by:
I have 5 years of MS Access/VBA development experience and am moving into the VB.net world. I am seeking a tutor which could facilitate this move. I live in Anderson, IN and am willing to...
6
by: Rhino | last post by:
What's the simplest way to determine which, if any, of my selectors are not needed in a given stylesheet? I have a small number of HTML pages that share two stylesheets; one stylesheet is for...
7
by: gregincolumbus | last post by:
Hello I have used chained selects to populate two selects. When the user chooses from first select, he is presented with the populated data for the 2nd select. The result is a list of numbers. ...
0
by: Rowland Smith | last post by:
Is anyone aware of a module or recipe for defining a composite/chained exception superclass? I've seen the PEP on chained exceptions wrt Python-3K, but I'm looking for something that is 2.5...
5
by: Nathan Sokalski | last post by:
I'm not sure if this is the right place to ask this question, but I wasn't sure where else to go. I have a table made of the following tags: <table class="myclass"> <tbody> <tr><td>.</td></tr>...
7
by: azura | last post by:
hello sir, anyone can help me where can i learn about chained select box because i want to make 3 chained select box and saved it into database
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: 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: 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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.