Changing UI dropdown list

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
benroll

April 20th, 2010, 3:39 am

Hi All,

I'm trying to make a UI where there are two drop down lists. The contents of the second drop down list needs to alter, according to what is selected in the first. Most of the standard Javascript array syntax I've tried doesn't work. Then I found this in another script...

pal.grp.main.aDropDown.add('item', 'hello');

...which successfully adds 'hello' to the end of the list. I extrapolated the syntax to....

pal.grp.main.aDropDown.remove('item', pal.grp.main.aDropDown.items[0]);

...and although it doesn't through an error, it doesn't have any effect either. I've tried setting the length to 0, using splice() and pop() etc. but all to no avail. Now I'm stumped.

How do I do this?

Thanks if you can help.

Ben.
benroll

April 20th, 2010, 3:41 am

Just found it!

pal.grp.main.aDropDown.remove(pal.grp.main.aDropDown.items[0]);

But if anyone can think of a nice succinct method to empty the list... or just set it to another list that doesn't use a loop and remove() to get rid of the elements one by one, I'd love to know about it.

Thanks.

Ben.
Dan Ebberts
Posts: 319
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

April 20th, 2010, 9:01 am

Did you try .removeAll() ?


Dan
Post Reply