Adding to listbox without refreshing..

J

JJ

I want to have two lists (may have to be listboxes) on a page that are
populated from a database.

I then need to be able to click on an entry in one box and add it to the
other, _preferably_ without refreshing the page.

Is this possible? Am I coming across another reason to venture into AJAX I
wonder....

What controls should I use for the lists to allow selection, sorting, etc
(listbox?).

Thanks in advance,

JJ
 
G

Guest

I want to have two lists (may have to be listboxes) on a page that are
populated from a database.

I then need to be able to click on an entry in one box and add it to the
other, _preferably_ without refreshing the page.

Is this possible? Am I coming across another reason to venture into AJAX I
wonder....

What controls should I use for the lists to allow selection, sorting, etc
(listbox?).

Thanks in advance,

JJ

if you need just to add a new option you can easily do it using pure
JavaScript

Example: http://www.mredkj.com/tutorials/tutorial005.html

But I think you would need to save that new option on the server side
(a database). I'm right?
 
M

Michael Nemtsev

Hello JJ,

Just to add to Alexey's post:

There are 2 possible solutions:
1) select everything for 2 listboxes at once, send all data to your JS as
2 arrays - one for the first listbox and second is the all values for your
selection in first listbox

2) Making async XmlHttpRequest, pumping the required info for the second
listbox. See intro for XHR there http://www.codeproject.com/Ajax/AjaxExplained.asp

If the set of values is small the first case is preferable

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

J> I want to have two lists (may have to be listboxes) on a page that
J> are populated from a database.
J>
J> I then need to be able to click on an entry in one box and add it to
J> the other, _preferably_ without refreshing the page.
J>
J> Is this possible? Am I coming across another reason to venture into
J> AJAX I wonder....
J>
J> What controls should I use for the lists to allow selection, sorting,
J> etc (listbox?).
J>
J> Thanks in advance,
J>
J> JJ
J>
 
J

JJ

Yes - its a case of adding a load of entries, then doing the database update
(I hope).
I'm trying to save on repeat database calls (for each entry added), and also
on page refreshes for each addition (but maybe this can't be avoided).

Perhaps its possible to select several entries in the one listbox, then
click submit to add them in one refresh...?

JJ
 
G

Guest

Yes - its a case of adding a load of entries, then doing the database update
(I hope).
I'm trying to save on repeat database calls (for each entry added), and also
on page refreshes for each addition (but maybe this can't be avoided).

Perhaps its possible to select several entries in the one listbox, then
click submit to add them in one refresh...?

JJ







- Show quoted text -

You can put a hidden field and populate it with the added items.

BTW, I found an interesting control, that might have what you need

Take a look at http://metabuilders.com/Tools/DualList.aspx
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top