Quantcast

[Moo] How to get a selected dropdown item's display text?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Moo] How to get a selected dropdown item's display text?

Jeff Dunlap
Dear users:
 
I'm having some difficulty getting the selected item's display text (i.e. 'Third') for a dropdown:
 
<select id="weightclass">
  <option value="1">First</option>
  <option value="2">Second</option>
  <option value="3">Third</option>
</select>
 
// using the 'value' property
var mystring = $('weightclass').get('value');    // returns 3
 
var mystring = $('weightclass').get('text');     // returns text for ALL of the items
 
Thank you
 
 
 
 

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] How to get a selected dropdown item's display text?

Sanford Whiteman
getSelected()[0].get('text')

            http://jsfiddle.broadleafsystems.com/urnD5/1/
           
-- S.

--

---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] How to get a selected dropdown item's display text?

Dimitar Christoff
In reply to this post by Jeff Dunlap
given that it's not multiple=multiple, then:

    $('weightclass').getSelected()[0].get('text');

getSelected will return a collection of all selected options. http://mootools.net/docs/core/Element/Element#Element:getSelected


On 4 June 2013 23:12, Jeff Dunlap <[hidden email]> wrote:
Dear users:
 
I'm having some difficulty getting the selected item's display text (i.e. 'Third') for a dropdown:
 
<select id="weightclass">
  <option value="1">First</option>
  <option value="2">Second</option>
  <option value="3">Third</option>
</select>
 
// using the 'value' property
var mystring = $('weightclass').get('value');    // returns 3
 
var mystring = $('weightclass').get('text');     // returns text for ALL of the items
 
Thank you
 
 
 
 

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Dimitar Christoff

"JavaScript is to JAVA what hamster is to ham"
@D_mitar - https://github.com/DimitarChristoff

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] How to get a selected dropdown item's display text?

Sanford Whiteman
I forgot to get the mutex on the mailing list, damn. :)

--

---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] How to get a selected dropdown item's display text?

Dimitar Christoff
think you won by a second. meh!


On 4 June 2013 23:27, Sanford Whiteman <[hidden email]> wrote:
I forgot to get the mutex on the mailing list, damn. :)

--

---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.





--
Dimitar Christoff

"JavaScript is to JAVA what hamster is to ham"
@D_mitar - https://github.com/DimitarChristoff

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] How to get a selected dropdown item's display text?

Sanford Whiteman
> think you won by a second. meh!

Huh, I thought you won, but I had a Fiddle.

Cheerz...

--

---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Moo] Re: How to get a selected dropdown item's display text?

Jeff Dunlap
In reply to this post by Jeff Dunlap
It worked perfectly and the link made it clear, thanks again!

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] Re: How to get a selected dropdown item's display text?

Tim Wienk
Sanford's email is timestamped 23 seconds before Dimitar's email,
however, Sanford's was only delivered to a mailserver 38 seconds later
(local mail client?), while Dimitar's was sent through gmail and was
delivered within seconds, in the end Dimitar's email was delivered 17
seconds before Sanford's.

So, maybe you both won, at a slightly different game. :-P

</offtopic>

I'm sure I can speak on behalf of both Dimitar and Sanford (alphabetic
order, no relation to who might have won), to say that you are most
welcome. :-)

--

---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Moo] Re: How to get a selected dropdown item's display text?

Rolf Langenhuijzen
++ for those analytics. can't you do that for every post?

On Wednesday, June 5, 2013 8:34:10 AM UTC+2, Tim Wienk wrote:
Sanford's email is timestamped 23 seconds before Dimitar's email,
however, Sanford's was only delivered to a mailserver 38 seconds later
(local mail client?), while Dimitar's was sent through gmail and was
delivered within seconds, in the end Dimitar's email was delivered 17
seconds before Sanford's.

So, maybe you both won, at a slightly different game. :-P

</offtopic>

I'm sure I can speak on behalf of both Dimitar and Sanford (alphabetic
order, no relation to who might have won), to say that you are most
welcome. :-)

--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Loading...