Javascript List Box(selection list)

They have: 39 posts

Joined: Jun 2000

I am using following code to add option to a list box

for (var i = 0; i < Engs.length; i++)
{if(document.dataform.PMPSA.value == Engs[i].PMPSANo)
{NewOpt = new Option;
NewOpt.value = Engs[i].No;
NewOpt.text = Engs[i].No + "-" + Engs[i].Description;
document.dataform.Engagement.options[document.dataform.Engagement.options.length] = NewOpt;
}
}

is it possible to select a particular option?

detox's picture

They have: 571 posts

Joined: Feb 2001

option selected does this, the problem is where in the list you want it. Simply do a check for the i value of the option you want, and doc.write the option selected in.

this is the simple code that you want to end up with:

fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
fsdfsdfasdfas
this one
fsdfsdfasdfas
fsdfsdfasdfas

If I have completely missed the intent of the question, i have to tell you I was out drinking pretty damn late last night!!!!!! so sorry!

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi dhaliwam,

Can't help but think I answered this somewhere else Laughing out loud

document......Engagement.options.length] = NewOpt;
if (i == someNumber)
document....Engagement.options.length].selected = true;

Hi detox: lookin gooood, mon Laughing out loud

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.