【发布时间】:2015-11-26 13:38:56
【问题描述】:
我需要在我的 mvc 模型上创建一个下拉列表菜单。样式切换器和按钮一样正常工作:
<form>
<input type="submit" onclick="switch_style('Ugly Default'); return false;" name="theme" value="Ugly_Default" id="Ugly_Default">
<input type="submit" onclick="switch_style('Redmond'); return false;" name="theme" value="Redmond" id="Redmond">
</form>
链接如下:
<link rel="stylesheet" type="text/css" href="http://localhost:57172/Content/site.css" title="Ugly_Default" >
<link rel="alternate stylesheet" type="text/css" href="http://localhost:57172/Content/Redmond.css" title="Redmond">
<script type="text/javascript" src="http://localhost:57172/Scripts/styleswitcher.js"></script>
到目前为止,我已经想出了这个解决方案,但没有效果:
<form name="theme" id="theme" onsubmit="return false;">
<select id="colourselector" name="theme" onchange="switch_style();">
<option value="Ugly_Default">Default</option>
<option value="Redmond">Redmond</option>
</select>
</form>
任何建议将不胜感激。提前致谢!
【问题讨论】:
-
函数'switch_style'需要一个参数(样式)。你应该重写它或创建一个新函数。
标签: javascript css razor