【问题标题】:javascript to redirect page pased on selected value [closed]javascript根据所选值重定向页面[关闭]
【发布时间】:2011-12-20 16:05:54
【问题描述】:

我尝试根据用户在下拉菜单中选择“标准”还是“维护”来重定向页面。 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>

【问题讨论】:

  • function formType(value) { window.location = "index.php?requestType=" + value; }

标签: javascript select redirect window.location


【解决方案1】:

您在函数末尾缺少}

【讨论】:

  • 谢谢!我现在因为错过了这么简单的东西而感到愚蠢......
【解决方案2】:

函数末尾缺少}。它应该是这样的:

function formType(value){
    if (value == 'maintenance') {
        window.location = "index.php?requestType=maintenance";
    } else {
        window.location = "index.php?requestType=standard";
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多