【发布时间】:2017-09-07 00:28:31
【问题描述】:
我正在尝试基于菜单选择获取文本框或另一个下拉菜单。我已经能够通过javascript函数做到这一点。现在我从这个网站得到了一些帮助:
how can select from drop down menu and call javascript function
但这只是我实现目标的一部分。例如,试图根据在菜单选项中选择“每日”来显示一些 html 功能,但可惜这不起作用。下面是我的代码,请你帮我调整一下这段代码,这样我就可以在下拉菜单中选择每天时显示嵌入在 javascript 中的 html 代码。
<!DOCTYPE html>
<html>
<body>
<select name="aa" onchange="report(this.value)">
<option value="">Please select</option>
<option value="daily">daily</option>
<option value="monthly">monthly</option>
</select>
<script>
function report(v) {
//To Do
switch(v) {
case "daily":
notification_var = "<hr>";
notification_var += "<table width=100% border=0>";
notification_var += "<tr>";
notification_var += "<td align=left width=30% style='align:left;padding-left:0px;height:30px;'><span id='toplink_daily_remarks'></span></td>";
notification_var += "<td align=center><label style='font-family:arial;font-weight:bold;font-size:1.2em;color:#000080;'>Daily Info and Remarks</label></td>";
notification_var += "<td width=30%> </td>";
notification_var += "</tr>";
notification_var += "</table>";
return notification_var;
break;
case "monthly":
//Do somthing
break;
}
}
</script>
</body>
</html>
【问题讨论】:
标签: javascript html menu