PDA

View Full Version : Refreshing a drop-down list/select list



bbrant
02-05-2007, 07:38 PM
I have a problem that I was hoping someone could help me with.

I have a picklist that is derived from a database table. The option value is the BANK_ID from the database while the BANK_NAME is what is displayed for the user. This works fine.

The problem arises when a new bank needs to be added to the list. Right now I have a pop-up window that allows users to enter a new bank to the database. This part also works fine. But when they go back to the picklist on the main/parent page, it does not display until the entire page is refreshed or reloaded.

Is there any way to refresh the picklist when the child form is closed so that users will see the new entry without having to reload the parent page? I tried to do an onFocus event to the select list that runs a function that will rerun the query but that didn't work.

Any help you can provide it GREATLY appreciated!

Thanks in advance.

Brian

jscheuer1
02-06-2007, 08:13 AM
Any javascript solution would have to be backed up by a non-javascript fall back. Can you 'get' back to the main page targeting its window by name? This would cause a reload. That could be your fall back. The javascript solution could involve code on the pop up. If this pop up was opened by the page you want updated, it can access an element on that page using the opener convention:


var newopt=opener.document.createElement('option');
newopt.value=whatever; //you can use database or other server tokens here*
newopt.text=whatever; //same here, this is the text displayed by the option
opener.document.forms['formname']['selectelementname'].appendChild(newopt);

This could be assigned to the event that 'gets' back to the main page but return false so that if javascript were enabled, no reload of the page would be required.



* If they were current at the time the code was parsed. If this is information being sent to the database from a form on the pop up, you could grab it from the form using javascript.