repopulate html select with new database call using JS?

B

bbcrock

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
 
R

RobG

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/>
 
I

impaler

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
 
B

bbcrock

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
 
R

RobG

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top