Forum Moderators: coopster

Message Too Old, No Replies

load data from db in combo based on the option of other combo

         

sanindhya

10:31 am on Jan 24, 2004 (gmt 0)

10+ Year Member



Hi,

I need a solution to load data from db in combo based on the option selected in the previous combo
for eg.,
1st combo have the list of countries(from db).
2nd combo should load the states(from db) based on the value we select in the country combo.

pls help me its very urgent

thanks in advance.

Birdman

1:43 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

If both <select>(combo) boxes are on the same page, you will have to use JavaScript to make the second <select> change.

If they are on different pages then PHP can do it easily.

How many options are in the first <select>?

sanindhya

5:47 am on Jan 27, 2004 (gmt 0)

10+ Year Member



Hi birdman,

Both are in the same page, and the 1st combo options would be increase in future. But now it will be 4(eg). But I dont know how to handle this in javascript. Because based on the 1st combo's option we need to load the 2nd combo with datas from database. What i am asking is to get data from db once again we need php right. If we go for php to get data from db the current page will get refresh right.

Here where I got stuck.

pls reply asap.

coopster

10:13 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's right, sanindhya, you'll need to load up the select lists from the database one way or another. The decision you have to make is:
  1. Should I load both lists at once and use CSS/JS to control the display?
  2. Should I ask the user to make the first selection, then go back to the server to load the second list?

One determining factor will be the amount of data in the selection lists. If list 1 has 100 choices, and each of those choices has 52 choices, that is quite a chunk of bandwidth compared to an initial selection and a new server request. Some things to consider, anyway.