|
|
#1 | |
|
Registered User
Join Date: Mar 2004
Posts: 15,486
|
right now i have two <select> items on a webpage. one represents companies and one represents projects.
the projects depend on which company is selected. how can i make the project dropdown box change automatically when the company dropdox box is changed? i am working in PHP and am open to java suggestions. thx. |
|
|
|
|
|
|
#2 | |
|
Sayonara !!!
Join Date: Jan 2003
Location: Austin, Texas
Posts: 9,297
|
Do you have a lookup table?
/me is thinking in terms of sql. If so, you SHOULD be able to have updated data on the drop-down menu depending on what the table's contents consist of. |
|
|
|
|
|
|
#3 | |
|
Registered User
Join Date: Mar 2004
Posts: 15,486
|
Quote:
im referring more to actually updating the projects list when the company list item is changed. say i have companies: A with projects 1,2,3 B with projects 4,5,6 C with projects 7,8,9 A is initially set and projects 1,2,3 are displayed. i want the project list to be changed to 4,5,6 as soon as the company list is changed to B. how would i do that? |
|
|
|
|
|
|
#4 | |
|
Ngemu Mod
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
|
Quote:
If you want the list to change without refreshing, you will need to use is either Javascript/Java to modify the HTML DOM select items you have on your page when an onChange event happens on the Company select box. There are many ways this can be done with Javascript. The issue is, the data is located on the server and would require: a: Data needs to be available to the javascript upon page load. b: Data can be pulled from the database asyncronously(AJAX). If you don't want to go the javascript route, you could post the page back onto itself everytime you select a different company from the list. The post data would contain the currently selected company and your php script can then use that POST data to fill the projects list. You could also try using a session variable to store the currently selected company. Of course this means everytime you select a different company from the list, the page reloads.
__________________
[i7 2600k @4.4ghertz][2x4 GB DDR3 1600][EVGA GTX570 1.280GB SC][EVGA GTX460 physx][Asrock Extreme7 Gen3 Z68][2xSeagate 160 Gb SATA HD raid0][Seagate 250 GB SATA2 HD][Sony Bravia 40' 1080p LCD HDTV][NEC 3520a DVD+-DLw][Windows 7 Ultimate x64][Rosewill 1000w] |
|
|
|
|
|
|
#5 | |
|
Registered User
Join Date: Mar 2004
Posts: 15,486
|
i figured out how to do it.
i added an "onchange" event that linked to a javascript function. the function was called with the value of the newly selected item (the variable this.value was passed to the function which just directed to a new page, which was the value of the select option). for each item, the value was set to the same page with a GET method. so the link was: pagename.php?company=selectedcompanyname then i used a $_GET['company'] call in PHP to get the value and set the selected item Quote:
![]() thx. |
|
|
|
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error on startx after updating drivers. | PktLoss | NVIDIA Linux | 3 | 09-24-02 09:58 PM |