需要帮助切换页面

时间:2015-11-02 03:22:32

标签: javascript html

我的功能需要帮助。我有我所有的变数。



var swith = document.getElementById("sub");
var one = document.getElementById("rule");
var two = document.getElementById("cool");
var three = document.getElementById("fool");

Function cool() {
	if(swith,one) window.location.replace("app.html");
};

<html>
<head>
<title>question?</title>
<link href="app.css" rel="stylesheet" type="text/css"/>
</head>
<body id="QA">	
<select id="much">
<option id="rule">0-10,000</option>
<option id="cool">25,00-50,000</option>
<option id="fool">75,000-100,000</option>
<input type="submit" id="sub">
<script src="app.js"></script>
</select>
</body>
</html>
&#13;
&#13;
&#13;

我想我错过了重要的事情。但谷歌声明&#34; Uncaught SyntaxError:意外的标识符&#34;。

2 个答案:

答案 0 :(得分:1)

f尝试小写Function,例如:

function cool() {
    if(swith,one) window.location.replace("app.html");
};

答案 1 :(得分:0)

与资本的关系&#34; F&#34;是javascript中的function constructor。 您应该使用常规函数表达式。

我建议不要在选项中添加id属性,而是添加一个值属性,并在提交包含的表单时,执行提交的逻辑。

我附加了一个原始代码段,您可以根据自己的需要进行扩展和修改。由于表单提交的沙箱,此代码段提交将无法在此站点上运行。

&#13;
&#13;
window.onload = function() {

  document.getElementById("TestForm").addEventListener("submit",function(e) {
    
      if (this.value === "rule") {
         document.location.replace('app.html');
      }
  },false);
  
 
};
&#13;
<html>

<head>
  <title>question?</title>
</head>

<body id="QA">
  <form id="TestForm" name="TestForm" action="#">
  <select id="much">
    <option value="rule">0-10,000</option>
    <option value="cool">25,00-50,000</option>
    <option value="fool">75,000-100,000</option>
  </select>
    <input type=submit value="Submit"/>
    </form>
</body>

</html>
&#13;
&#13;
&#13;

相关问题