Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the select box values in YUI 3?

Tags:

yui

yui3

In YUI 3 I have a node that is my select box:

Y.get('#regionSelect');

How do I get the <option> values that are currently selected (even if there are more than one?) Also, is there a tutorial out there that tells me explicitly how to do this (I don't want to serialize a whole form)?

like image 712
atp Avatar asked Jul 28 '09 21:07

atp


1 Answers

Once you have the selector, you can chain get and each

Y.get("#regionSelect").get("options").each( function() {
   // this = option from the select
   var selected = this.get('selected');
   var value  = this.get('value');
   var text = this.get('text');
   // apply secret sauce here
});

I've just been using the demos/examples on http://developer.yahoo.com/yui/3/ to figure things out.

like image 189
seth Avatar answered Sep 28 '22 03:09

seth