Go Back   nV News Forums > Software Forums > Software Development

Newegg Daily Deals

Reply
 
Thread Tools
Old 05-25-07, 02:48 PM   #1
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Need help with updating entries automatically...

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.
ViN86 is offline   Reply With Quote
Old 05-25-07, 02:57 PM   #2
Sazar
Sayonara !!!
 
Sazar's Avatar
 
Join Date: Jan 2003
Location: Austin, Texas
Posts: 9,297
Default Re: Need help with updating entries automatically...

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.
Sazar is offline   Reply With Quote
Old 05-25-07, 02:59 PM   #3
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Re: Need help with updating entries automatically...

Quote:
Originally Posted by Sazar
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.
yes im using mysql to retrieve the companies and projects (projects are linked to the companies table).

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?
ViN86 is offline   Reply With Quote
Old 05-25-07, 03:16 PM   #4
fivefeet8
Ngemu Mod
 
Join Date: Jul 2003
Location: Fresno, CA
Posts: 1,886
Default Re: Need help with updating entries automatically...

Quote:
Originally Posted by ViN86
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.
PHP is a server side language. To make any changes appear on the page requires a refresh with updated data.

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]
fivefeet8 is offline   Reply With Quote
Old 05-26-07, 09:09 AM   #5
ViN86
 
Join Date: Mar 2004
Posts: 15,486
Default Re: Need help with updating entries automatically...

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:
Originally Posted by fivefeet8
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.
yes, this is what i did pretty much
thx.
ViN86 is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


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

All times are GMT -5. The time now is 12:50 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.