网址重定向

发布于 2024-11-29 00:43:11 字数 2573 浏览 2 评论 0原文

我有一个包含以下代码的虚拟机文件:

更新:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

与他有关 2024-12-06 00:43:11

打字错误? 它就会起作用。

document.forms[this].action

如果您更改为

document.forms["adform"].action

编辑

您还有var fwork = document.getElementById('FW');然后是fwork.value.toString()FWDIV 而不是 SELECT

将选择更改为

< strong>编辑 2

您的 fwork.value.toString() == "wap" 永远不会为 true,因为 "WAP" 的唯一出现是 <选项 ID = “wap”>w-Net 这不是 .value

将 HTML 更改为:

        <select name="frwork" id = "frwork">
            <option value=""></option>
            <option value="jqm">jQuery Mobile</option>
            <option value = "wap">Webapp-Net</option>
            <option value = "tst">a Test</option>
        </select>

要读取所选的,请将:替换

if (fwork.value.toString() == "wap") {

为:

if (fwork.options[fwork.selectedIndex].value == "wap") {

Typo? it would work if you changed:

document.forms[this].action

to

document.forms["adform"].action

Edit

You also have var fwork = document.getElementById('FW');then later fwork.value.toString() but FW is a DIV not the SELECT.

Change the select to <select id="frwork" name="frwork"> and read it with var 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:

        <select name="frwork" id = "frwork">
            <option value=""></option>
            <option value="jqm">jQuery Mobile</option>
            <option value = "wap">Webapp-Net</option>
            <option value = "tst">a Test</option>
        </select>

And to read the selected value replace:

if (fwork.value.toString() == "wap") {

with:

if (fwork.options[fwork.selectedIndex].value == "wap") {
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文