By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

COmbo box

P: 27
Hi all
This may appear as silly question.But if anyone knows please help me.I am using php and mysql.
I have got a combo box to select Employeee Department.
After choosing a Department ,section should be selected.Then the related sections of that particular department should only appear in that combobox.
I am using an html form to enter these details.How can i embed the php code for this in that form.

Thanks in advance
Aug 25 '08 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
personally I would try an AJAX-driven solution first. nevertheless you need somehow to specify, which section belongs to which department. For that you can use a database, a (two dimensional) array or an object. you feed php with the first selection from $_GET or $_POST, determine from that and the (let's say) database the correct values for the second selection and return them.
Aug 25 '08 #2

Markus
Expert 5K+
P: 6,050
Hey there.

Check out this tutorial.

Regards
Aug 25 '08 #3

FLEB
P: 30
The key point-- what others are alluding to-- is that you need JavaScript to change the value of the next select-box without re-loading the page.

One thing I would add, too, is that you may consider non-AJAX JavaScript as well, especially if there aren't many categories or subcategories. Just use PHP to retrieve the entire list of categories and output it as either a JavaScript array*, then build the menus from that. (Personally, I would doubt that a smaller set such as a dropdown/category list would necessarily warrant creating a more complicated asynchronous app. Keep the KISS principle in mind.)

* If you're feeling adventurous, and want to maintain compatibility for non-JavaScript browsers, you could use the PHP to generate a hierarchical HTML form structure-- a UL list or such-- that gets converted into dynamic boxes by JavaScript, if JavaScript is available.
Aug 26 '08 #4

Post your reply

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