0

我尝试根据用户在下拉菜单中选择“标准”还是“维护”来重定向页面。Hoewever 我的 javascript 不能正常工作。你能帮我指出我哪里出错了吗?

提前致谢。

    <script type="text/javascript">
    <!--
    function formType(value){
        if (value == 'maintenance') {
            window.location = "index.php?requestType=maintenance";
        } else {
            window.location = "index.php?requestType=standard";
        }
    -->
    </script>
    <select id="changer" name="type" onchange="formType(this.value);">
              <option value="standard" <?php if ($requestType == 'standard') { echo "selected"; } ?>>Standard</option>
              <option value="maintenance" <?php if ($requestType == 'maintenance') { echo "selected"; } ?>>Maintenance</option>
    </select>
4

2 回答 2

2

}您在函数末尾缺少 a 。

于 2011-11-02T20:23:38.267 回答
0

}您的功能末尾缺少一个。它应该是这样的:

function formType(value){
    if (value == 'maintenance') {
        window.location = "index.php?requestType=maintenance";
    } else {
        window.location = "index.php?requestType=standard";
    }
}
于 2011-11-02T20:27:05.597 回答