from A to B

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Dark_AngeL
Forum Commoner
Posts: 39
Joined: Tue Feb 21, 2006 5:16 am

from A to B

Post by Dark_AngeL »

Hi I need help in this

please bare with me alittle

ok say this is my window

Image

in A are all the item we have in the system which are entered from a different form. and say i want to chose and item from A and move it to B how can i do it?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This is a Javascript question. Moved to Client-side.


I know we've talked about this, but can't seem to find the thread(s) I'm thinking of..
Dark_AngeL
Forum Commoner
Posts: 39
Joined: Tue Feb 21, 2006 5:16 am

Post by Dark_AngeL »

sorry didn't know that its a Javascript question
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

The recently released Yahoo UI Library might be useful: http://developer.yahoo.net/yui/dragdrop/index.html
Dark_AngeL
Forum Commoner
Posts: 39
Joined: Tue Feb 21, 2006 5:16 am

Post by Dark_AngeL »

Code: Select all

<script language="JavaScript" type="text/javascript">
<!--

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}

//-->
</script>
I find this code but i need someone to explain it for me
darryladie
Forum Commoner
Posts: 62
Joined: Thu Mar 02, 2006 6:14 pm
Location: East Sussex, UK

Post by darryladie »

What do you know about programming, do you know what a function and parameter are? *prays* :lol:
Post Reply