Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 4th, 2010  |  syntax: JavaScript  |  size: 1.06 KB  |  hits: 89  |  expires: Never
download  |  raw  |  embed  |  report abuse
This paste has a previous version, view the difference. Copied
  1. // switch boxes
  2. function moveSelectedOptions(from,to) {
  3.         // Unselect matching options, if required
  4.         if (arguments.length>3) {
  5.                 var regex = arguments[3];
  6.                 if (regex != "") {
  7.                         unSelectMatchingOptions(from,regex);
  8.                 }
  9.         }
  10.         // Move them over
  11.         for (var i=0; i<from.options.length; i++) {
  12.                 var o = from.options[i];
  13.                 if (o.selected) {
  14.                         to.options[to.options.length] = new Option( o.text, o.value, false, false);
  15.                         // var optGrps = to.getElementsByTagName("optgroup");
  16.                         //optGrps.insertBefore(new Option( o.text, o.value, false, false) , this.firstChild);
  17.                        
  18.         //              try {
  19.         //                      to.add(new Option( o.text, o.value, false, false),to.options[0]);
  20.         //              }catch(ex) {
  21.         //                      to.add(new Option( o.text, o.value, false, false),0);
  22.         //              }
  23.                 }
  24.         }
  25.         // Delete them from original
  26.         for (var i=(from.options.length-1); i>=0; i--) {
  27.                 var o = from.options[i];
  28.                 if (o.selected) {
  29.                         from.options[i] = null;
  30.                 }
  31.         }
  32.         if ((arguments.length<3) || (arguments[2]==true)) {
  33.                 //sortSelect(from);
  34.                 //sortSelect(to);
  35.         }
  36.         from.selectedIndex = -1;
  37.         to.selectedIndex = -1;
  38. }