repopulate html select with new database call using JS?

Discussion in 'Javascript' started by bbcrock@gmail.com, Jan 13, 2006.

  1. Guest

    Unfortunately my users are demanding this functionality:
    They are on a form. Click on an "add" button. An html window pops up.
    They add a new item that is saved to the database. The window closes.
    The HTML select box REFRESHES itself with the new informaiton (Primary
    key and text field) WITHOUT submitting the form.

    I tried to get away with a text box on the form that would dynamically
    repopulate the select box, but no-go- they want to follow the above
    process exactly with the new window, etc.

    What is the easiest and most cross-browser compatible way to run a new
    database query and repopulate the select box? It sounds like Ajax to
    me, but I'd rather go with a less MS-centric solution.

    Feel free to just point me to a cookbook link, I couldn't find one
    online

    thanks for everything!!!

    Don
    , Jan 13, 2006
    #1
    1. Advertising

  2. RobG Guest

    wrote:
    > Unfortunately my users are demanding this functionality:
    > They are on a form. Click on an "add" button. An html window pops up.
    > They add a new item that is saved to the database. The window closes.
    > The HTML select box REFRESHES itself with the new informaiton (Primary
    > key and text field) WITHOUT submitting the form.
    >
    > I tried to get away with a text box on the form that would dynamically
    > repopulate the select box, but no-go- they want to follow the above
    > process exactly with the new window, etc.
    >
    > What is the easiest and most cross-browser compatible way to run a new
    > database query and repopulate the select box? It sounds like Ajax to
    > me, but I'd rather go with a less MS-centric solution.


    AJAX isn't MS centric at all, though they were first to introduce
    XMLHttpRequest it is now widely implemented in recent browsers (IE 5+,
    Mozilla 1.0+, Safari 1.2+, Opera 8, others including Firefox, not sure
    when it started supporting it but cetainly since 1.0).

    Given your scenario, the best idea is to have the pop-up send data to
    the main window, then the main window update the database and return
    new values for the select using XMLHttpRequest (aka AJAX), then update
    the select.

    Don't be tempted to use the pop-up to send the data to the database and
    update the select asynchronously - you need to ensure that the database
    part worked before updating the select.

    There are other techniques that don't use AJAX, e.g. submit a form in a
    hidden frame so the user never sees it happen.

    >
    > Feel free to just point me to a cookbook link, I couldn't find one
    > online


    Try:

    <URL:http://www.ajaxtoolbox.com/>



    --
    Rob
    RobG, Jan 13, 2006
    #2
    1. Advertising

  3. VK Guest

    wrote:
    > Feel free to just point me to a cookbook link, I couldn't find one
    > online


    <http://www.ajaxtoolbox.com>
    VK, Jan 13, 2006
    #3
  4. impaler Guest

    > Don't be tempted to use the pop-up to send the data to the database and
    > update the select asynchronously - you need to ensure that the database
    > part worked before updating the select.


    why not ?

    If you do the update in the popup, and everything went fine, I presume
    you have a confirmation and a button that says 'OK' or 'CLOSE'.
    Delegate a javascript function for the onclick event of the button that
    updates the select in the opener.
    Or if you close the popup after success, then put the populating
    function in the window.onunload and it will work or simply call a
    function with the necessary parameters from the opener that does this.

    Regards
    impaler, Jan 13, 2006
    #4
  5. Guest

    That is how the structure of my system currently works- The user saw
    the ok button and at the click of the ok, I closed the window. then I
    wanted to trigger a refresh.

    also when I said I was looking for a less MS-centric solution, I
    suppose what I meant was, a solution that would require that every
    browser in the fleet would be up to date- which I can't control and
    comes back to bite me in user testing.

    thanks!!!

    Don
    , Jan 13, 2006
    #5
  6. RobG Guest

    impaler wrote:
    >>Don't be tempted to use the pop-up to send the data to the database and
    >>update the select asynchronously - you need to ensure that the database
    >>part worked before updating the select.


    Who wrote that? Oh, me.


    > why not ?


    Because...

    >
    > If you do the update in the popup, and everything went fine, I presume
    > you have a confirmation and a button that says 'OK' or 'CLOSE'.
    > Delegate a javascript function for the onclick event of the button that
    > updates the select in the opener.
    > Or if you close the popup after success, then put the populating
    > function in the window.onunload and it will work or simply call a
    > function with the necessary parameters from the opener that does this.


    Which is updating the opener synchronously - so you agree with me.



    --
    Rob
    RobG, Jan 14, 2006
    #6
  7. Guest

    yes, asynchronous updating of the style you mean was not in my plan.

    Don
    , Jan 17, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TaeHo Yoo
    Replies:
    4
    Views:
    741
  2. luna_s

    popup repopulate

    luna_s, Mar 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    338
    Teemu Keiski
    Mar 6, 2004
  3. JN

    Repopulate TreeView

    JN, Jan 26, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,134
  4. =?Utf-8?B?Y2luZHk=?=
    Replies:
    0
    Views:
    506
    =?Utf-8?B?Y2luZHk=?=
    Sep 21, 2006
  5. sking
    Replies:
    1
    Views:
    99
    Tad McClellan
    Mar 22, 2005
Loading...

Share This Page