Advanced Search

Results 1 to 2 of 2

Thread: Refreshing a drop-down list/select list

  1. #1
    Join Date
    May 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Refreshing a drop-down list/select list

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    27,637
    Thanks
    42
    Thanked 2,896 Times in 2,868 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •