...

View Full Version : Can I use PHP to display drop down list based on another drop down list?



Sherrie
01-06-2007, 12:47 AM
Hi all!

I'd like to have 3 drop down lists connected.

Division
Department and
Section

Where the options of Department are dependent on what is selected in Division and the options of Section are dependent on what is selected in Department.

So far, all the examples I've found have been using JavaScript. Can I do this in PHP as I have no knowledge of JavaScript at all!

If so, can someone please show me some sample code or direct me to more information?

Thanks a bunch!

Len Whistler
01-06-2007, 12:54 AM
The problem with PHP is that the page has to reload to get the sub-catagories. With JavaScript sub-catagories are displayed instantly, which is way better.

JavaScript is easy to learn and I recommend you use JavaScript in this case. You will need to know JavaScript for Ajax, which has lots of potential.

Sherrie
01-06-2007, 01:03 AM
Len,

Thank you for your quick reply!

How would I incorporate JavaScript into my PHP file? :o

Len Whistler
01-06-2007, 01:12 AM
Len,

Thank you for your quick reply!

How would I incorporate JavaScript into my PHP file? :o

I'm not on my home computer for exact syntax but you can have javascript code outside of php code:


<?php
?>
Javascript code
<?php
?>

OR

Use php to echo the javascript code.

Sherrie
01-06-2007, 01:26 AM
Thanks again!

Would you be able to recommend any Javascript resources?

I have the sample code for linking the 2 combo boxes, but I don't understand most of it! :p

Sorry to be such a pain

Len Whistler
01-06-2007, 02:07 AM
Thanks again!

Would you be able to recommend any Javascript resources?

I have the sample code for linking the 2 combo boxes, but I don't understand most of it! :p

Sorry to be such a pain


Post in the Javascript forum here on CodingForums. They will have you up and running very quickly.

Sherrie
01-06-2007, 06:16 AM
Thanks! Will do that!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum