User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,222 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,280 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3909 | Replies: 34 | Solved
Reply
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Cascading Dropdown list with (AJAX, PHP)

  #21  
Jul 9th, 2008
@Shanti, the sql you have posted (location and state.sql) are corrupted.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #22  
Jul 9th, 2008
Hi.. Nav..
Check this attatchment now...
Thanks.
Tanha Check this anf go through that with previous attatch ments...
Last edited by Shanti Chepuru : Jul 9th, 2008 at 6:35 am.
Attached Files
File Type: txt 1onetable.txt (865 Bytes, 6 views)
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Cascading Dropdown list with (AJAX, PHP)

  #23  
Jul 9th, 2008
Originally Posted by Shanti Chepuru View Post
Hi.. Nav..
Check this attatchment now...
Thanks.

This is fine!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #24  
Jul 9th, 2008
Thank you Naveen....
Reply With Quote  
Join Date: Aug 2007
Posts: 167
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #25  
Jul 9th, 2008
Dear Shanti,
it is ok, can u post the location.sql file too ?
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #26  
Jul 9th, 2008
Im so sorry tanha..
Presently it is not in my computer...
Reply With Quote  
Join Date: Jul 2008
Posts: 1
Reputation: spazzlady is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
spazzlady spazzlady is offline Offline
Newbie Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #27  
Jul 10th, 2008
Anyone able to help me with the following attachments? I'm able to select value from the first drop down list. But the second drop down list value would be that of the first drop down list. Like a repeat. I'm new at this, not sure how do I get value from another table from the database for the second drop down list. I'm trying to get card_name from the card table for the second dropdown list. Been looking at it for days. And stucked. Hope someone can help?
Attached Files
File Type: zip ajax.zip (4.5 KB, 6 views)
Reply With Quote  
Join Date: Jul 2008
Location: Sweet India
Posts: 828
Reputation: Shanti Chepuru is on a distinguished road 
Rep Power: 2
Solved Threads: 74
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Practically a Posting Shark

Re: Cascading Dropdown list with (AJAX, PHP)

  #28  
Jul 10th, 2008
Hello spazzlady...
I have seen your attachment , in that ,i think your issuer table is wrong.
Means , issuer table has no subcategories...Thats why repetition is done...
So tel me from which table you have to get values to the second drop down...
Reply With Quote  
Join Date: Sep 2007
Posts: 9
Reputation: badbart is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
badbart badbart is offline Offline
Newbie Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #29  
Jul 10th, 2008
Thanks to all of your guidance (this was my first time playing with AJAX), I've come up with a more configurable version of the cascading dropdown list code that my fellow Ajax-noobs might find helpful.

Here is what's in the attached zip:
AjaxCode.js - this is essentially the same as the other javascript files that have been posted here with a few minor tweaks.
data_settings.php - this is a file that's included in the php pages that query the database. It contains the hostname, username, password, and database name for the database that will house the tables, creates the database connection and selects the database.
index.php - this is a more dynamic main page that builds itself using two tables. The first table, ajax_data, contains all the data to be placed in the dropdowns. The second table, ajax_labels, contains the descriptions labels for each dropdown and more importantly, an id field that determines the value passed in the onchange event to load the dependent dropdown options.
tables.sql - this is the sql to build and fill the generic tables used by the code. You can add any number of dropdowns by adding records to ajax_labels and ajax_data with the proper corresponding id (in the label table) and parent & level (in the ajax_data table).
xml_data_provider.php - this is essentially the same file as was attached in the first post, with the required tweaks to make it work.


One question for you AJAX experts: Do you have any idea why using an ampersand in the text description (the book title in my attached example) causes an error? To duplicate the error, just replace the word "and" with "&" in any of the titles.
For example, this causes an error:
<mxml><parent_level name="1"><child_level id="9">The Hitchhiker`s Guide to the Galaxy</child_level></parent_level><parent_level name="1"><child_level id="10">The Restaurant at the End of the Universe</child_level></parent_level><parent_level name="1"><child_level id="11">Life, the Universe, & Everything</child_level></parent_level><parent_level name="1"><child_level id="12">So Long and Thanks for all the Fish</child_level></parent_level><parent_level name="1"><child_level id="13">Mostly Harmless</child_level></parent_level><parent_level name="1"><child_level id="14">Dirk Gently`s Holisitic Detective Agency</child_level></parent_level><parent_level name="1"><child_level id="15">The Salmon of Doubt</child_level></parent_level><parent_level name="1"><child_level id="16">Last Chance to See</child_level></parent_level></mxml>
Attached Files
File Type: zip ajax_cascading_list.zip (4.0 KB, 2 views)
Reply With Quote  
Join Date: Sep 2007
Posts: 9
Reputation: badbart is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
badbart badbart is offline Offline
Newbie Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #30  
Jul 11th, 2008
I just discovered that the multi-level (beyond 2 dropdowns) logic is flawed. I'll post the fix as soon as I figure out where the problem is.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC