Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

I am trying to alert a value from a Select menu.

I have tried both:
alert(JSON.stringify(Appery("Contact_Select").val()));

alert(Appery("Contact_Select").val());

but instead of getting the text of the selected element in Contact_Select I only get a " or ,

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Get value from Select

Hi Milton,

Have you tried with code.text();/code instead of code.val();/code

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

Yes, that was returning all text labels for each item, not just the selected ones.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Get value from Select

You want to return only selected ones?

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

Yes. The text or value from only the selected items.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Get value from Select

Try this way:
prealert(Appery('myselectmenu').find(':selected').text());/pre

  • where 'myselectmenu' is the name of your select component.
Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

This does not work either...

alert($("#Contact_Select option:selected").text());

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

That worked! Thank you very much

Milton Davis
Posts: 0
Joined: Tue Mar 04, 2014 5:12 am

Get value from Select

Any suggestions on how to make this return a comma seperated list? Right now it is returning multiple items but combining then into one string with no spaces.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Get value from Select

Hello!

To get array of all records use the following code:
prevar arr = [];
Appery('myselectmenu').find(':selected').each( function() {
arr.push($(this).val())
})/preAfter you get array you can expose it any way you need.

Return to “Issues”