This is a migrated thread and some comments may be shown as answers.

How do I get the selected value of a combobox using javascript?

2 Answers 541 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Iron
Acadia asked on 01 Apr 2009, 01:15 PM
I can get an instance of the combobox but can't seem to get the currently selected value using Javascript.

Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Apr 2009, 01:36 PM
Hi Acadia,

Try the get_value() method for getting the SelectedValue and get_text() for SelectedItem text.

JavaScript:
<script type="text/javascript">  
function  getSelected()  
{  
    var combo = $find('<%=RadComboBox1.ClientID %>');      
    var value = combo.get_value();  
    var text = combo.get_text();  
    alert("Selected Text  :" + text);  
    alert("Selected Value :" + value);  
}  
</script> 

Checkout the following links
Client-Side Basics
RadComboBox object

Thanks,
Princy.
0
Acadia
Top achievements
Rank 1
Iron
answered on 01 Apr 2009, 01:44 PM

Thanks Princy - I had actually ended up using this

 

 

var combo = <%= radcmbWEDates.ClientID %>;

 

 

var combotext = document.getElementById(combo.InputID).value;

It gets me the text, which is fine.  I had tried the two methods you suggested and for some reason they were always null.

 

Tags
ComboBox
Asked by
Acadia
Top achievements
Rank 1
Iron
Answers by
Princy
Top achievements
Rank 2
Acadia
Top achievements
Rank 1
Iron
Share this question
or