<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script language="JavaScript">
<!--
function GaiBian(osel){
alert(osel.options[osel.selectedIndex].text);
}
//-->
</script>
</head> <body>
<select name='selectSS' onChange="GaiBian(this)">
<option value='1'>1 </option>
<option value='2'>2 </option>
<option value='3'>3 </option>
</select>
</body>
</html>
解决方案 »
- jquery 插件 找了很久不知道为什么
- JS怎样检测页面是否有object标签?
- 请教select如何实现回应键盘type,自动选中item,并自动scroll to 到该选中的item
- 这问这函数有什么作用
- 请教高手:当鼠标指针移动速度太高时,能不能限制它去触发(onMouseOver,onMousemove)事件?
- 请问不准用户关闭新打开的窗口,请问如何写?
- 能否去掉IE浏览器窗体左上方的图标?
- 请问有没有JavaScript写的MD5加密程序?有下载吗?
- Jquery中的Dialog 窗口上的富文本编辑器(CKEditor 或者freetextbox)产生冲突,文本框无法编辑输入文本问题
- JavaScript 运行时错误: 无法获取未定义或 null 引用的属性“tags”
- [JS]关于Textarea输入输出和时间显示的几个小问题[急~需在周三晚上前结帖]
- 我的一段javascript程序报"缺少标识符、字符串或数字"错,可我怎么也找不到是那儿错了。各位帮忙看看啊
var $=function(Id){
return document.getElementById(Id)?document.getElementById(Id):Id;
};
var $N=function(Name){
return document.getElementsByName(Name)?document.getElementsByName(Name):Name;
};
//获取select的值
var $S=function(Id){
return $(Id).options[$(Id).selectedIndex].value;
}
//获取radio的值
var $R=function(name){
var radio = $N(name);
var getresult = 0;
for (var i=0;i<radio.length;i++){
if(radio[i].checked)
getresult = radio[i].value;
}
return getresult;
};
//调用$S("select的id名")
<html>
<body>
<script type="text/javascript">
var prevVal = null;
window.onload = saveSel;
function $(id){
return document.getElementById(id);
}
function saveSel(){
prevVal = $("selectSS").options[$("selectSS").selectedIndex].value;
}
function GaiBian(){
if(prevVal != null){
alert("选择之前的值:"+prevVal);
}
saveSel();
alert("现在的值:" + prevVal);
}
</script>
<select name='selectSS' id="selectSS" onChange="GaiBian()">
<option value='1'>1 </option> <option value='2'>2 </option> <option value='3'>3 </option>
</select>
</body>
</html>
<!--
function GaiBian(obj){
alert(obj.options[obj.selectedIndex].value);
}
//-->
</script>