Click to See Complete Forum and Search --> : defining <addSrcToDestList>


kwok3d
04-29-2003, 06:45 PM
----------------------------
function addSrcToDestList() {
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;
var len = destList.length;
for(var i = 0; i < srcList.length; i++) {
if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
//Check if this value already exist in the destList or not
//if not then add it otherwise do not add it.
var found = false;
for(var count = 0; count < len; count++) {
if (destList.options[count] != null) {
if (srcList.options[i].text == destList.options[count].text) {
found = true;
break;
}
}
}
------------------------------

what does this do:
destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;

thx

khalidali63
04-29-2003, 06:55 PM
From your code it looks like they are

destList = window.document.forms[0].destList;
srcList = window.document.forms[0].srcList;

HTML list box object references.

This line of code
if (srcList.options[i].text == destList.options[count].text) {
found = true;

shows that you are comparing 2 values from 2 drop down( list box elements)

and if a value is matched it sets a variable to true and stops looking any further.

Make sense?

kwok3d
04-29-2003, 07:28 PM
What I don't understand is why the variable destList is declared as a value of sorts at the end if the defining the variable.
What I want to do is take names(strings) and list them in another frame--I can make it work using a textbox where the displayed list is in text format, but I want them in list format so that I can easily remove them from the list with a 'remove' button.
Any help will be most appreciated by this hopeful novice.