Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 2nd, 2005, 07:50 AM
Registered User
 
Join Date: Aug 2005
Location: Bangalore, Karnataka, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to valentine
Default list box item moved up and down with focus

This code is used for the functionality of list box.
In this list box item can be selected and moved up and down without "loosing focus",and its applicable to Multiple selction also.

-----------------------------cut this code and paste----------------
<script type="text/javascript">
        function BumpUp(abox)
                {
                  for(var i = 0; i < abox.options.length; i++)
                  {
                    if(abox.options[i].value == "")
                    {
                      for(var j = i; j < abox.options.length - 1; j++)
                      {
                        abox.options[j].value = abox.options[j + 1].value;
                        abox.options[j].text = abox.options[j + 1].text;
                      }
                      var ln = i;
                      break;
                    }
                  }
                  if(ln < abox.options.length)
                  {
                    abox.options.length -= 1;
                    BumpUp(abox);
                  }
              }

        function Moveup(dbox)
                {
                  //alert("moving up");
                  for(var i = 0; i < dbox.options.length; i++)
                  {
                    if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0])
                    {
                      var selected = dbox.options[i].selected;
                      var tmpval = dbox.options[i].value;
                      var tmpval2 = dbox.options[i].text;
                      dbox.options[i].value = dbox.options[i - 1].value;
                      dbox.options[i].text = dbox.options[i - 1].text
                      dbox.options[i-1].value = tmpval;
                      dbox.options[i-1].text = tmpval2;
                      if(selected)
                      {
                        dbox.options[i-1].selected = true;
                      }
                      else
                      {
                        dbox.options[i-1].selected = false;
                      }
                      dbox.options[i].selected = false;
                    }
                  }
                }

        function Movedown(ebox)
                {
                  if(ebox != null)
                  {
                    var size =ebox.options.length;
                    if(size > 0)
                    {
                      for(i=(size-1); i>=0; i--)
                      {
                        var obj1 = ebox.options[i];
                        if((obj1 != null) && (obj1.selected==true))
                        if((i+1) < size)
                        {
                          // Swap the elements.
                          var tempVal = ebox[i].value;
                          var tempTxt = ebox[i].text;
                          ebox[i].value = ebox[i+1].value;
                          ebox[i].text =ebox[i+1].text;
                          ebox[i+1].value = tempVal;
                          ebox[i+1].text = tempTxt;
                          ebox[i].selected = false;
                          ebox[i+1].selected = true;
                        }
                      }
                    }
                  }
                }
</script>

Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Variey item in list box limit quatitiy and compare apple88 Classic ASP Databases 0 June 18th, 2007 02:25 AM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
Get the first item of a List hpox ASP.NET 2.0 Basics 1 February 16th, 2007 05:04 PM
Setting Text Box Focus sathish_reddy ASP.NET 1.0 and 1.1 Professional 1 November 22nd, 2006 01:26 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM



All times are GMT -4. The time now is 12:35 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.