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 391,990 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 4,296 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: 2472 | Replies: 34 | Solved
Reply
Join Date: Jun 2008
Location: Delhi
Posts: 119
Reputation: vicky_rawat is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 15
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #31  
Jul 11th, 2008
hi,

I am here giving answers to two questions.

1. & gives error: This is because some characters are reserved characters in XML and & is one of them, so if you need & in description then you will need to entity references.
some examples are as follows:

& - the & character
&lt; - the < character
&gt; - the > character
&apos; - the ' character
&quot; - the " character


2. AJAX, cookies needs to be deleted frequently: This is because when AJAX calls a page, it searches for it first in cache, so the changes if any have been done will not be reflected.

To prevent it, always add a randam value in querystring when calling a page.
This will let AJAX know that we need a page from server and not from Cache.

Hope these things will help you guys.
Vivek Rawat
Keep solving complexities.
Reply With Quote  
Join Date: Aug 2007
Posts: 147
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)

  #32  
Jul 11th, 2008
To prevent it, always add a randam value in querystring when calling a page.
This will let AJAX know that we need a page from server and not from Cache.

Hi, thanks for the info
How should we do this ?
Reply With Quote  
Join Date: Jun 2008
Location: Delhi
Posts: 119
Reputation: vicky_rawat is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 15
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Cascading Dropdown list with (AJAX, PHP)

  #33  
Jul 12th, 2008
Hi Tanha,

when you create a xml request, you create a url somewhat like this, right?

   requestUrl = "xml_data_provider.php?level="+index+"&parent=" + selectedItem;

just add dat time to it, it will never be used but will make the page request a new request everytime.

   requestUrl = "xml_data_provider.php?level="+index+"&parent=" + selectedItem+"&"+date;
Vivek Rawat
Keep solving complexities.
Reply With Quote  
Join Date: Aug 2007
Posts: 147
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)

  #34  
Jul 12th, 2008
I will use that, thanks again
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)

  #35  
Jul 14th, 2008
Originally Posted by badbart View Post
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.

I've corrected the problem with the multi-level loading and added a button to reset the select controls.

I hope somebody finds it useful. If not, it was still fun coming up with the solution.
Attached Files
File Type: zip ajax_cascading_list.zip (4.3 KB, 1 views)
Reply With Quote  
Reply

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

Currently Active Users Viewing This Thread: 2 (1 members and 1 guests)

dwsmart

DaniWeb PHP Marketplace
Thread Tools Display Modes

Other Threads in the PHP Forum

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