请教一个关于下拉框的问题

bisliu 2004-11-05 01:38:53
我想在改变下拉框内容的同时做一个提交,刷新一次页面。
代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Expires" content="0">
<link HREF="../css/styles.css" REL="STYLESHEET" TYPE="text/css">
<title>test</title>
</head>
<body>
<form name=fquery method=post action="Page">
<input type=hidden name="search" value=Y>
<div align="center"><center><table border="0" cellspacing='1' cellpadding='0' class="DTab">
<tr><th class="DTh">
test
<select name="cCode" value="">
<option></option>
<option value = "AN323"> 111</option >
<option value = "AN32311"> 222</option >
</select>
</th></tr>
</table></center></div>
</form>
<script>
fquery.cCode.onchange=fquery.submit;
</script>
</body>
</html>
可是,好像没反映,如果把fquery.submit改成alert(111),也只是在第一次刷新页面的时候会有弹出框,而且ie还报了“尚未实现”的错误,这是为什么?我知道可以直接写在select的后面,那这样写为什么不对呢?哪位高手能指点一下,十分感谢!
...全文
118 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
anycat 2004-11-05
  • 打赏
  • 举报
回复
<select onchange="SelectedChange(this)" >...

<script language="javascript">
function SelectedChange(selecter)
{
alert(selecter.options[selecter.selectedIndex].value);// use this to get Selected Value
// add your code to refresh page here.
}
</script>

=-------------------
hope this would be helpful.
^_^
heyixiang 2004-11-05
  • 打赏
  • 举报
回复
你要在外面取得select的参数,必须用循环,如同下面这个radio

function GetRadioValue(radName){
var radGroup=document.all(radName);
for(var iCnt=0;iCnt<radGroup.length;iCnt++)
if(radGroup[iCnt].checked) return radGroup[iCnt].value;
}
bisliu 2004-11-05
  • 打赏
  • 举报
回复
我知道可以直接写在select的后面,我想知道的是为什么javascript不能写在外面。
那如果是写在js文件里,要在这里引入怎么办?
heyixiang 2004-11-05
  • 打赏
  • 举报
回复
楼主是要上面的效果不?
heyixiang 2004-11-05
  • 打赏
  • 举报
回复
<form name="frm" method="post" action="">
<select name="select" onChange="this.form.aaa.value=this.value;">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<br>
<br>
<input type="text" name="aaa">
</form>
yaohai 2004-11-05
  • 打赏
  • 举报
回复
up,学习!!
bisliu 2004-11-05
  • 打赏
  • 举报
回复
up
bisliu 2004-11-05
  • 打赏
  • 举报
回复
谢谢楼上两位的指点,我想知道的是为什么javascript不能写在外面,不能这样写
<script>
fquery.cCode.onchange=fquery.submit;
</script>
那如果是写在js文件里,要在这里引入怎么办?
ttyp 2004-11-05
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Expires" content="0">
<link HREF="../css/styles.css" REL="STYLESHEET" TYPE="text/css">
<title>test</title>
<script language="JavaScript">
<!--
function su()
{
fquery.action = "test.asp?tmp=" + fquery.cCode.options[fquery.cCode.selectedIndex].value;
fquery.submit();
}
//-->
</script>
</head>
<body>
<form name=fquery method=post action="Page">
<input type=hidden name="search" value=Y>
<div align="center"><center><table border="0" cellspacing='1' cellpadding='0' class="DTab">
<tr><th class="DTh">
test
<select name="cCode" onchange="su()">
<option></option>
<option value = "AN323"> 111</option >
<option value = "AN32311"> 222</option >
</select>
</th></tr>
</table></center></div>
</form>
</body>
</html>
qfljm 2004-11-05
  • 打赏
  • 举报
回复
<select name="cCode" onchange="fquery.submit();">
<option></option>
<option value = "AN323"> 111</option >
<option value = "AN32311"> 222</option >
</select>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧