<select id="sel" onchange="javascript:getSelect();">
<option value="a">选择</option>
<option value="bdd">be</option>
<option value="c">ce</option>
<option value="d">de</option>
<option value="e">ee</option>
</select>
<script>
function getSelect() {
//得到select下拉列表中option的value
var optionValue = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].value;
//得到select下拉列表中option的text
var optionText = document.getElementById("sel").options[document.getElementById("sel").options.selectedIndex].text;
}
</script>
<select id="sele" onchange="javascript:getE();">
<option value="monday">星期一</option>
<option value="tuesday">星期二</option>
<option value="wednesday">星期三</option>
<option value="thursday">星期四</option>
<option value="friday">星期五</option>
</select>
<script>
function getE() {
//我建议这里也像下面一些写,虽然这样写也可以获得数据
var optionsValue = document.getElementById("sele").value;
alert(optionsValue);
var optionsText = document.getElementById("sele").options[document.getElementById("sele").options.selectedIndex].text;
alert(optionsText);
}
</script>
分享到:
相关推荐
最关键的一段代码就是: 代码如下: onchange=”show(this.options[this.options.selectedIndex].value);” onchange=”show(this.options[this.options.selectedIndex].value);” show是一个自定义的函数名。 this....
this.TitleTable.cells(0).childNodes(0).innerText = this.options[this.selectedIndex].innerText; if (this.bExpanded) this.toggleOptions(false); } function SS_toggleTitle (bReverse) { this....
return $(this).get(0).selectedIndex; } //获得当前选中项的文本 jQuery.fn.getSelectedText = function(){ if(this.size() == 0) return "下拉框中无选项"; else{ var index = this.getSelectedIndex...
onchange="ChangeSelect('../Ajax.asp?Type=1&Id;='+this.options[this.options.selectedIndex].value,'ztzlid');")
所以用的代码是: onChange=”window.open(this.options[this.selectedIndex].value,’_blank’)” 但这样很容易被屏蔽的…有更好的办法吗可以用变通的方法, 1.页面用<a></a> 2.document.getElementById(‘aa’)....
objSelect.onchange = Function( "var val = this.options[this.selectedIndex].value;BindSelect(m_sBaseSrc+val, '"+objSelect.ChildSelectName+"', '"+defaultVal+"');if(val!='')document.all....
如下所示: 1.获取option的value的值,watch option 控件时,或自动获取option的value的值。...select name=type onchange=show_sub(this.options[this.options.selectedIndex].value)> 请选择主菜名 <o
二、导航功能增强 1. 下拉菜单中的链接(Links in Select Menu) Q:我如何实现在下拉菜单中链接到不同的页面?...self.location=this.options[this.selectedIndex].value”> ”” selected>Sele
var YYYYvalue = document.form1.YYYY.options[document.form1.YYYY.selectedIndex].value; if (YYYYvalue == ""){ var e = document.form1.DD; optionsClear(e); return;} var n = MonHead[str - 1]; if (str ==...
空闲时间用javaME制作的一个菜单小工具,构造函数如下public MenuList(String[] menuOptions, int SelectedIndex, int IntPositionX, int IntPositionY, int IntNumArrowhead) { this.IntSelectedIndex = ...
本文实例讲述了JavaScript获取select中text值的...select name=parent_id onchange=setTitleAndLinkByGoodsCategory(this.value,this.options[this.selectedIndex].text); > 请选择商品分类 家电 数码 <optio
if (this.page > this.pageCount) this.page = this.pageCount; this.page = parseInt(this.page); this.pageCount = parseInt(this.pageCount); } showPages.prototype.createHtml = function(mode){ //生成html...
select name=’page’ onChange=\”[removed].href='” + fileName + temp + “cur_page=’+this.options[this.selectedIndex].value\”>”; 已经试过了,没问题 1.以下是实现分页的类PageResultSet 代码如下:...
this.selectedIndex=0; //输入时,一但有匹配的项,就默认选择第一项,这样,再按回车键,即可直接submit提交 jht添加 2011-07-20 $(".auto_selected_val").val(d); } 3. 当输入正确值,而不去选择相应提示项...
Ajax实现无刷新三联动下拉框 ... <title>Ajax实现无刷新三联动下拉框 ... <SCRIPT language="javascript"> //城市------------------------------ function cityResult() ... /// the contents of this method...
这是一款基于js实现select跳转菜单新...select onchange=window.open(this.options[this.selectedIndex].value) name=select> <option value=//www.jb51.net/jiaoben/ selected=selected>脚本下载 <option valu
和大家分享一下代码: JavaScript代码 代码如下: //得到select项的个数 jQuery.fn.size = function() { return jQuery(this).get(0).options.length; } //获得选中项的索引 jQuery.fn.getSelectedIndex = function()...
这里是js的代码: 代码如下: jQuery.fn.size = function() { return jQuery(this).get(0).options.length; } //获得选中项的索引 jQuery.fn.getSelectedIndex = function() { return jQuery(this).get(0)....
在编程过程中,我们对下拉列表框的取值很多时候都是获取option中的value,但是也有需要获取显示在页面中的值的时候,例如想获得”...select onchange=”a(this.options[this.selectedIndex].innerText);”><o
targ+”.location='”+selObj.options[selObj.selectedIndex].value+”‘”); if (restore) selObj.selectedIndex=0; } –> 2.使用 代码如下: ”yq”>校友会链接:</p> <p> <label> <select name=”select2″...