<html>
<head>
<script language="JavaScript" type="text/javascript">
function butRemoveWed_onclick()
{
if (document.form1.theDay.options[2].text == "Wednesday")
{
document.form1.theDay.options[2]=null;
}
else
{
alert("There is no Wednesday here!");
}
}
function butAddWed_onclick()
{
if (document.form1.theDay.options[2].text != Wednesday")
{
var indexCounter;
var days=document.form1.theDay;
var lastoption=new option();
days.options[6]=lastoption;
for (indexCounter=6; indexCounter>2; indexCounter--)
{
days.options[indexCounter].text=days.options[indexCounter-1].text;
days.options[indexCounter].value=days.options[indexCounter-1].value;
}
var option=new option ("Wednesday",2);
days.options[2]=option;
}
else
{
alert("Do you want to have TWO Wednesdays?????");
}
}
</script>
</head>
<body>
<form name=form1>
<select name=theDay size=5>
<option value=0 selected>Monday
<option value=1>Tuesday
<option value=2>Wednesday
<option value=3>Thursday
<option value=4>Friday
<option value=5>Saturday
<option value=6>Sunday
</select>
<input type="button" value="Remove Wednesday" name=butRem onclick="butRemoveWed_onclick()">
<input type="button" value="Add Wednesday" name=butAd onclick="butAddWed_onclick()">
</form>
</body>
</html>
button 的onclick事件怎么也不触发。请帮忙。谢谢
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
7条回答 默认 最新
- 斯洛文尼亚旅游 2016-11-29 08:28关注
function butAddWed_onclick() { if (document.form1.theDay.options[2].text != "Wednesday")/////////////少了引号 { var indexCounter; var days = document.form1.theDay; var lastoption = new Option();//////没注意大小写 days.options[6] = lastoption; for (indexCounter = 6; indexCounter > 2; indexCounter--) { days.options[indexCounter].text = days.options[indexCounter - 1].text; days.options[indexCounter].value = days.options[indexCounter - 1].value; } var option = new Option("Wednesday", 2);;//////没注意大小写 days.options[2] = option; } else { alert("Do you want to have TWO Wednesdays?????"); } }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥20 西南科技大学数字信号处理
- ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
- ¥30 STM32 INMP441无法读取数据
- ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现
- ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
- ¥15 用visualstudio2022创建vue项目后无法启动
- ¥15 x趋于0时tanx-sinx极限可以拆开算吗
- ¥15 pyqt信号槽连接写法
- ¥500 把面具戴到人脸上,请大家贡献智慧,别用大模型回答,大模型的答案没啥用
- ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。