By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,101 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,101 IT Pros & Developers. It's quick & easy.

repopulate html select with new database call using JS?

P: n/a
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 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
bb*****@gmail.com 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
Jan 13 '06 #2

P: n/a
VK

bb*****@gmail.com wrote:
Feel free to just point me to a cookbook link, I couldn't find one
online


<http://www.ajaxtoolbox.com>

Jan 13 '06 #3

P: n/a
> 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

Jan 13 '06 #4

P: n/a
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 '06 #5

P: n/a
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
Jan 14 '06 #6

P: n/a
yes, asynchronous updating of the style you mean was not in my plan.

Don

Jan 17 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.