/    Sign up×
Community /Pin to ProfileBookmark

defining <addSrcToDestList>


—————————-

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Apr 29.2003 — 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?
Copy linkTweet thisAlerts:
@kwok3dauthorApr 30.2003 — 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.
×

Success!

Help @kwok3d spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...