ScriptUI DropDownList and onChange

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Anybody have any luck with getting a DropDownList to work with onChange?

What I am trying to do is avoid a "Do it" button. I want to simply have the function trigger when the drop down list is changed..

Like this:

pal.grp.OQ.List.selection.onChange = function () {
alert("yo");
}

but it doesn't seem to work.. buttons and checkboxes with onClick seem to work fine..

-Lloyd
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

lloydalvarez wrote:Anybody have any luck with getting a DropDownList to work with onChange?
pal.grp.OQ.List.selection.onChange = function () {
alert("yo");
}

but it doesn't seem to work.. buttons and checkboxes with onClick seem to work fine..

-Lloyd
i already replied to lloyd directly, but if anyone else is curious, the onChange callback is for the dropdownlist object (List), so it needs to be:

Code: Select all

pal.grp.OQ.List.onChange = function () {
					alert("yo, you selected item " + this.selection.index);
}
i added the this.selection.index to the alert so you can tell which item (beginning with 0, as selection is an array) was selected.

:jeff
ScottHD
Posts: 11
Joined: June 14th, 2008, 9:22 pm
Location: South Carolina

Here is a snippet of my code on how I got it to work for one of my DropDownList scripts:

Code: Select all

				pal.grp = pal.add(res);
				  pal.layout.layout(true);
                  pal.grp.minimumSize = pal.grp.size;
                  pal.layout.resize();
                  pal.onResizing = pal.onResize = function () {this.layout.resize();}
				pal.grp.header.help.onClick = function () {alert(aeMarketsData.scriptTitle  + "\n" + aeMarketsData.strAbout);}
				pal.grp.DropDownList.onChange = function () {
					if (this.selection != null) {
						for (var g = 0; g < this.items.length; g++)
						this.items[g].group.visible = false; //hide all other groups
						this.selection.group.visible = true;//show this group
						}
					}
				var item = pal.grp.DropDownList.add('item', 'Akron Real Estate');
				item.group = pal.grp.allGroups.akRe;
				pal.grp.allGroups.akRe.Panel1.name.b1.onClick = function () {renderSelectedComp320x240FLV(this.parent.parent, false);}
				pal.grp.allGroups.akRe.Panel2.name.b2.onClick = function () {renderSelectedComp7secFLV(this.parent.parent, false);}
I only show here one of the 17 (!) options in the drop down list array in this script. Of course the DropDownList Array calls back up to a very extensive list of UI Groups in the "var res =" instanceof Panel section above all of this which in itself took a good while to script. Maybe this can give you or someone else another idea. :-)
Post Reply