网址重定向
我有一个包含以下代码的虚拟机文件:
更新:
<html>
<head>
<title>Input Form</title>
<style>
#FW{
display: none;
}
</style>
<script type="text/javascript">
function showSelect()
{
var post = document.getElementById('post');
var fwork = document.getElementById('FW');
fwork.style.display = post.selectedIndex == 1 ? 'block' : 'none';
}
function getMeThere(){
var post = document.getElementById('post');
var fwork = document.getElementById('frwork');
if( post.value.toString() == "dpost"){
document.forms["adform"].action="https://google.com" ;
document.forms["adform"].method="post" ;
}
else{
if(fwork.value.toString() == "wap"){
document.forms["adform"].action="https://mail.yahoo.com" ;
document.forms["adform"].method="post" ;
}
else {
document.forms["adform"].action="bbc.co.uk" ;
document.forms["adform"].method="post" ;
}
}
document.forms["adform"].submit() ;
}
</script>
</head>
<body>
<form name="forum" id="adform" >
<label>Payment Amount:</label>
<input type = "text" name="paymentAmount" value=""/>
<label> Reference:</label>
<input type = "text" name="Reference" value=""/><br />
<label>Choose post</label><br/>
<select name="postCode" onchange="showSelect()" id = "post">
<option value="dpost">Desktop post</option>
<option value="mpost">Mobile post</option>
</select><br/>
<div id = "FW">
<label>Choose Your Toolkit</label><br/>
<select name="frwork" id = "frwork">
<option id=""></option>
<option id="jqm">jQuery Mobile</option>
<option id = "wap">Webapp-Net</option>
<option id = "tst">a Test</option>
</select>
</div>
<input type="submit" onclick="getMeThere()"/>
</form>
</body>
重定向根本不起作用,我似乎找不到问题。请注意,这些网址是假的,因为出于安全问题我可以发布真实的网址。
I have a VM file with the following codes:
UPDATED:
<html>
<head>
<title>Input Form</title>
<style>
#FW{
display: none;
}
</style>
<script type="text/javascript">
function showSelect()
{
var post = document.getElementById('post');
var fwork = document.getElementById('FW');
fwork.style.display = post.selectedIndex == 1 ? 'block' : 'none';
}
function getMeThere(){
var post = document.getElementById('post');
var fwork = document.getElementById('frwork');
if( post.value.toString() == "dpost"){
document.forms["adform"].action="https://google.com" ;
document.forms["adform"].method="post" ;
}
else{
if(fwork.value.toString() == "wap"){
document.forms["adform"].action="https://mail.yahoo.com" ;
document.forms["adform"].method="post" ;
}
else {
document.forms["adform"].action="bbc.co.uk" ;
document.forms["adform"].method="post" ;
}
}
document.forms["adform"].submit() ;
}
</script>
</head>
<body>
<form name="forum" id="adform" >
<label>Payment Amount:</label>
<input type = "text" name="paymentAmount" value=""/>
<label> Reference:</label>
<input type = "text" name="Reference" value=""/><br />
<label>Choose post</label><br/>
<select name="postCode" onchange="showSelect()" id = "post">
<option value="dpost">Desktop post</option>
<option value="mpost">Mobile post</option>
</select><br/>
<div id = "FW">
<label>Choose Your Toolkit</label><br/>
<select name="frwork" id = "frwork">
<option id=""></option>
<option id="jqm">jQuery Mobile</option>
<option id = "wap">Webapp-Net</option>
<option id = "tst">a Test</option>
</select>
</div>
<input type="submit" onclick="getMeThere()"/>
</form>
</body>
The redirection doesn't work at all, and I can't seem to find the problem. please notice that the URLs are fake, because I could post the real URL due to security issues.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
打字错误? 它就会起作用。
如果您更改为
编辑,
您还有
var fwork = document.getElementById('FW');
然后是fwork.value.toString()
但FW
是 DIV 而不是SELECT
。将选择更改为
< strong>编辑 2
您的
fwork.value.toString() == "wap"
永远不会为 true,因为"WAP"
的唯一出现是<选项 ID = “wap”>w-Net
这不是.value
。将 HTML 更改为:
要读取所选的值,请将:替换
为:
Typo? it would work if you changed:
to
Edit
You also have
var fwork = document.getElementById('FW');
then laterfwork.value.toString()
butFW
is a DIV not theSELECT
.Change the select to
<select id="frwork" name="frwork">
and read it withvar fwork = document.getElementById('frwork');
Edit 2
Your
fwork.value.toString() == "wap"
will never be true as the only occurence of"WAP"
is<option id = "wap">w-Net</option>
which is not a.value
.Change the HTML to:
And to read the selected value replace:
with: