Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > repopulate html select with new database call using JS?

Reply
Thread Tools

repopulate html select with new database call using JS?

 
 
bbcrock@gmail.com
Guest
Posts: n/a
 
      01-13-2006
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

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      01-13-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      01-13-2006

(E-Mail Removed) wrote:
> Feel free to just point me to a cookbook link, I couldn't find one
> online


<http://www.ajaxtoolbox.com>

 
Reply With Quote
 
impaler
Guest
Posts: n/a
 
      01-13-2006
> 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

 
Reply With Quote
 
bbcrock@gmail.com
Guest
Posts: n/a
 
      01-13-2006
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

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      01-14-2006
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
 
Reply With Quote
 
bbcrock@gmail.com
Guest
Posts: n/a
 
      01-17-2006
yes, asynchronous updating of the style you mean was not in my plan.

Don

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dynamic datagrid dropdown valuechanged repopulate 2nd list editmo =?Utf-8?B?Y2luZHk=?= ASP .Net 0 09-21-2006 04:40 PM
Repopulate TreeView JN ASP .Net 0 01-26-2006 03:39 AM
quickist way to repopulate a html form sking Perl Misc 1 03-22-2005 02:13 PM
popup repopulate luna_s ASP .Net 1 03-06-2004 05:47 PM
How to repopulate a dropdown list without posting back? TaeHo Yoo ASP .Net 4 07-23-2003 07:07 AM



Advertisments