populate users from "select many list box control "to another when selected

thanks in advance:

When Selected populate from one selectmanylist box control to another

But when i look in the java script console it is generating an error :

"option has no properties"

[code]

generated in frame source:

<select id="frmSecMsgEntry:lstBoxUsers" name="frmSecMsgEntry:lstBoxUsers" multiple class="selectManyListbox" size="5" style="width: 250px"><option value="ELANYADMIN">Persaud, Brian</option>

</select></TD>

my java script code:

function func_2() {

//alert(fbox+'\n'+tbox)

fbox = frmSecMsgEntry:lstBoxUsers;

tbox = frmSecMsgEntry:lstBoxReceiveUsers

for(var i=0; i<fbox.options.length; i++) {

if(fbox.options.selected && fbox.options.value != "") {

var no = new Option();

no.value = fbox.options.value;

no.text = fbox.options.text;

//Check no dups are added

var bAdd = true;

for (var j=0; j><tbox.options.length; j++) {

if (no.value == tbox.options[j].value) {

bAdd = false;

}

}

if (bAdd) {

tbox.options[tbox.options.length] = no;

}

fbox.options.selected = false;

}

}

}

/code]>

[1282 byte] By [rajureddya] at [2007-10-2 19:41:02]
# 1

i figured it out,and working fine:

here is the code:

function add(thisObj, thisEvent) {

//Get the source and destination select many list box controllers

var source = document.getElementById('frmSecMsgEntry:lstBoxUsers');

var destination = document.getElementById('frmSecMsgEntry:lstBoxReceiveUsers');

//Check for the source not to be null

if(source != null){

for(var i=0; i<source.length; i++){

//check for selected and the value is not null ,create a new option with the

//text and value set the detination control with the created value

if(source.options.selected && source.options.value != ""){

var no = new Option();

no.value = source.options.value;

no.text = source.options.text;

}

//Check for no duplicates are added to the destination control

var flag = true;

for(var j=0; j><destination.length; j++){

if(no.value == destination.options[j].value)

flag = false;

}

//If the options is not there in the destination Control then "flag " will be

//"true"

if(flag){

destination.options[destination.options.length] = no;

}else

alert("Already Selected");

source.options.selected = false;

}

}

}

function addAll(thisObj, thisEvent) {

//Copy every thing from the source to destination when this button is pressed

//Get the source and destination select many list box controllers

var source = document.getElementById('frmSecMsgEntry:lstBoxUsers');

var destination = document.getElementById('frmSecMsgEntry:lstBoxReceiveUsers');

//Check for the source not to be null

if(source != null){

for(var i=0; i><source.length; i++){

//create a new option with the

//text and value set the detination control with the created value

//if(source.options.selected && source.options.value != ""){

var no = new Option();

no.value = source.options.value;

no.text = source.options.text;

//}

//Check for no duplicates are added to the destination control

var flag = true;

for(var j=0; j><destination.length; j++){

if(no.value == destination.options[j].value)

flag = false;

}

//If the options is not there in the destination Control then "flag " will be

//"true"

if(flag){

destination.options[destination.options.length] = no;

}else

alert("Already Selected");

source.options.selected = false;

}

}

}

function remove(thisObj, thisEvent) {

//Remove the selected item from the list ,make the selected item to "null"-

// to remove from the list

//Get the source and destination select many list box control's from the page

var source = document.getElementById('frmSecMsgEntry:lstBoxUsers');

var destination = document.getElementById('frmSecMsgEntry:lstBoxReceiveUsers');

//Check for the source not to be null,loop through the selected and make them null

if(source != null){

for(var i=destination.length-1; i>-1; --i){

if(destination.options.selected)

destination.options = null;

}

}

}function removeAll(thisObj, thisEvent) {

//Remove the selected item from the list ,make the selected item to "null"-

// to remove from the list.Since it is remove all ,set every thing to "null"

//Get the source and destination select many list box control's from the page

var source = document.getElementById('frmSecMsgEntry:lstBoxUsers');

var destination = document.getElementById('frmSecMsgEntry:lstBoxReceiveUsers');

//Check for the source not to be null,loop through the selected and make them null

if(source != null){

for(var i=destination.length-1; i>-1; --i){

//if(destination.options.selected)

destination.options = null;

}

}

}

rajureddya at 2007-7-13 22:19:03 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...