SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Resource

Reordering Items in an HTML Listbox


Sponsored Links
Developer's Paradise : Inside Technique :
Reordering Items in an HTML Listbox
Submission by SiteExperts Staff

Go to the resource:
Reordering Items in an HTML Listbox

Add to Assistant

Short Description
Learn how to use client-script to reorder listboxes and server-script to process the results.

Long Description
Using script, we show you how to:

  • Write a simple cross-browser javascript to reorder the contents of a listbox,
  • Pass the results to a server in a hidden field,
  • and process the results on the server using ASP and VBScript.
Author
Scott Isaacs
Date/ Version
1/12/2000
Submission URL
http://www.SiteExperts.com/tips/elements/ts32/page1.asp
Submission Date
Jan 12,2000
Last Update
Jan 12,2000
 

Discussion and Rate this Resource
Overall Rating: 4.1

ljuliuss on Apr 27, 2007 at 12:32:06 PMRating: 5

This is very cool and I'd like to implement it on a web page I'm developing as a front-end to a GIS page I'm having to write. Unfortunately, I am a real beginner at this and I cannot figure out exactly how to implement it on my server. CAN SOMEONE PLEASE HELP ME! Where does the Server Script go? Into a new file, or in the other code somewhere? If in a new file, what should it be named? I've been struggling for days.

Thanks for any help -  LJ

babul.mehta on May 7, 2005 at 7:42:28 PMRating: 5
excellent.....
gilgalbiblewheel on Dec 31, 2004 at 5:52:50 PMNo Rating
How do you do with a single table with a trio of listboxes: book/chapter/verse? I have one table with one verse per record.
lukemcd on Jul 27, 2004 at 9:09:41 AMRating: 4
There is an error in item order when items loop to the top or bottom of the list. Play with it and you will see. Thanks to Chris Rickard who posted a fix when I asked about the problem on the SiteExperts forums. Replace the "move" function with this one:

function move(form, direction, name)
{
var listBox = form.elements["ro_lst" + name];
var index = listBox.selectedIndex;

if (index == -1)
{
alert("You must first select the item to reorder.")
}
else
{
var option = listBox.options[index];
if(direction)
{
if(index == 0)
listBox.appendChild(option);
else
listBox.insertBefore(option,listBox.options[index-1]);
}
else
{
if(index == listBox.options.length-1)
listBox.insertBefore(option, listBox.firstChild);
else
listBox.insertBefore(option,listBox.options[index+2]);
}
}
}
bearwalk on May 4, 2002 at 4:53:30 PMRating: 5
Very nice. It inspired me to write an extension: two selectboxes, where you can move options from one to the other, and then sort them.

More Ratings/ Comments


To rate and comment on a resource, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password

Copyright © 1997-2008 InsideDHTML.com, LLC. All rights reserved.