If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Move value from onelist box to another

Started by sharon, 25 Feb 2014 06:30:32 AM

Previous topic - Next topic

sharon

I want  to develop one requirement as "moving values from one list box to another using javascript". I don't have any JS for cognos. Anyone please help me. I have Javascript for this. but its not working fine.

<script language="javascript">
function move(tbFrom, tbTo)
{
var arrFrom = new Array(); var arrTo = new Array();
var arrLU = new Array();
var i;
for (i = 0; i < tbTo.options.length; i++)
{
  arrLU[tbTo.options.text] = tbTo.options.value;
  arrTo = tbTo.options.text;
}
var fLength = 0;
var tLength = arrTo.length;
for(i = 0; i < tbFrom.options.length; i++)
{
  arrLU[tbFrom.options.text] = tbFrom.options.value;
  if (tbFrom.options.selected && tbFrom.options.value != "")
  {
   arrTo[tLength] = tbFrom.options.text;
   tLength++;
  }
  else
  {
   arrFrom[fLength] = tbFrom.options.text;
   fLength++;
  }
}

tbFrom.length = 0;
tbTo.length = 0;
var ii;

for(ii = 0; ii < arrFrom.length; ii++)
{
  var no = new Option();
  no.value = arrLU[arrFrom[ii]];
  no.text = arrFrom[ii];
  tbFrom[ii] = no;
}

for(ii = 0; ii < arrTo.length; ii++)
{
var no = new Option();
no.value = arrLU[arrTo[ii]];
no.text = arrTo[ii];
tbTo[ii] = no;
}
}
</script>

<input type="button" onClick="move(this.form.FromLB,this.form.ToLB)"
value="->">

<input type="button" onClick="move(this.form.ToLB,this.form.FromLB)"
value="<-">

Anyone give me a correct Javascript for that,

Thanks
sharon