用于从组合框中获取所选值的JavaScript代码 [英] JavaScript code for getting the selected value from a combo box
本文介绍了用于从组合框中获取所选值的JavaScript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以给我一个从现有组合框中获取所选值的示例代码吗?
Can any one give me a sample code that gets the selected value from an existing combo box?
我有这段代码,但它没有做任何事情:
I have this code but its not doing anything:
function check ()
{
var e = document.getElementById("ticket_category_clone");
var str = e.options[e.selectedIndex].text;
alert(str);
if (str==="Hardware")
{
SPICEWORKS.utils.addStyle('#ticket_c_hardware_clone{display: none !important;}');
}
}
SPICEWORKS.app.helpdesk.ready(check);
下载 img 的代码
和代码
<select id="ticket_category_clone" name="ticket[category]" hdpp="ticket_category">
<option value=""></option><option value="Hardware">Hardware</option>
<option value="Software">Software</option>
<option value="Rede" selected="selected">Rede</option>
<option value="Pedidos">Pedidos</option>
<option value="Formação/Dúvida">Formação/Dúvida</option>
<option value="Outro">Outro</option><option value="#edit_categories#">Edit Categories...</option></select>
我希望它找到一种方法来获得组合框的选定值
what i want its find a way to get the selected value fo that combobox
推荐答案
有一个不必要的主题标签;将代码更改为:
There is an unnecessary hashtag; change the code to this:
var e = document.getElementById("ticket_category_clone").value;
这篇关于用于从组合框中获取所选值的JavaScript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文