简体   繁体   English

使用javascript获取aspxcombobox值

[英]get aspxcombobox value using javascript

I have a aspxcombobox with ID="comboSubjectCategory", can I get the selected value/text using javascript function? 我有一个ID =“ comboSubjectCategory”的aspxcombobox,我可以使用javascript函数获取选定的值/文本吗? thanks lot...I tried this but it does not works. 非常感谢...我尝试了这个,但是没有用。

function getValue() {
   var combo = document.getElementById('comboSubjectCategory').value;
   alert(combo);
}

The ASPxComboBox is not a simple HTML element. ASPxComboBox不是简单的HTML元素。 In the browser, it is represented by the ASPxClientComboBox Class . 在浏览器中,它由ASPxClientComboBox类表示。 Use its GetValue , GetText or GetSelectedItem methods to obtain the selected value. 使用其GetValueGetTextGetSelectedItem方法获取选定的值。

You can obtain the ASPxClientComboBox instance by the name assigned to the ClientInstanceName property of the ASPxComboBox control. 您可以通过分配给ASPxComboBox控件的ClientInstanceName属性的名称来获取ASPxClientComboBox实例。

See Also: Client-Side Functionality 另请参见: 客户端功能

var combo = document.getElementById('<%= comboSubjectCategory.ClientID %>');
var val = combo.options[combo.selectedIndex].value;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM