nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   Need help with updating entries automatically... (http://www.nvnews.net/vbulletin/showthread.php?t=92130)

ViN86 05-25-07 02:48 PM

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.

Sazar 05-25-07 02:57 PM

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.

ViN86 05-25-07 02:59 PM

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?

fivefeet8 05-25-07 03:16 PM

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.

ViN86 05-26-07 09:09 AM

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.


All times are GMT -5. The time now is 01:27 AM.

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