我正在处理一个页面,该页面应该根据用户在表单中输入的内容进行重定向,但我似乎无法弄清楚。Javascript 新手,渴望学习!
这是html:
<body>
<div id="header">
<div id="navcontainer">
<ul>
<li> <a href="#item1">Home</a> </li>
<li> <a href="#item2">Scents</a> </li>
<li> <a href="#item3">About</a> </li>
<li> <a href="#item4">Contact</a> </li>
</ul>
</div>
</div>
<div id="content">
<p>Hi, how are you feeling today?</p>
<form> <input id="feels" type="text" name="feeling" size="35" onchange="checkfeels(#feels.value);">
<input type="submit" value="submit" >
</form>
</div>
到目前为止,我拥有的 Javascript:
function checkfeels(myFeels) {
switch (myFeels)
{
case "good":
document.location.href = 'scents.html';
break
case "bad":
alert(2);
document.location.href = 'scents2.html';
default:
alert("whatever");
}
}
非常感谢任何帮助,谢谢!