JS广播按钮值仅显示第二页,但不显示第三页

发布于 2025-02-10 07:30:46 字数 2516 浏览 1 评论 0原文

我的第二页有两个无线电按钮,可以确定VoIP或带宽以及电子邮件的文本字段。当我进入第三页时,我会按预期看到URL中的值。但是,当我提交持续时间时,我只能在URL而不是电子邮件或TestType中获得持续时间。

我还有5页,我希望参数累积。

HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
    </head>
    <body>
        <form id="myForm" onsubmit="goPFour(event)" method="get">
            <div id="pBFContainer" class="container">
                <div id="bodyFOption1">
                    <label for="testTime">How long would you like the VoIP test to run?<p></label>
                    <input type="radio" class="testD" name="testTime" value="10" checked/>10 Seconds
                    <input type="radio" class="testD" name="testTime" value="20" />20 Seconds
                </div>
            </div>
            <input type="submit" id="subButton" value="Next..." />
        </form>
    </body>
    <script type="text/javascript" src="evalportalp1.js"></script>
</html>

JS:

function goPFour(event) {   
    event.preventDefault();
    const formData = new FormData(event.target);
    const userEmail = formData.get("email");
    const testType = formData.get("testType");
    const testTime = formData.get("testTime")

    if (testTime === "10") {
        //console.log("testTime is 10");
        window.location.href = "evalportalv4.html?" + "email=" + userEmail + "&testType=" + testType + "&testTime=" + testTime;
    } else if (testTime === "20") {
        //console.log("testTime is 20");
        window.location.href = "evalportalv4.html?" + "email=" + userEmail + "&testType=" + testType + "&testTime=" + testTime;
    } else {
        alert("Please pick a valid Option");
    }
    return false;
}
function goPThree(event) {  
    event.preventDefault();
    const formData = new FormData(event.target);
    const userEmail = formData.get("email");
    const testType = formData.get("testType");

    if (testType === "voip") {
        //console.log("testtype is voip");
        window.location.href = "evalportalv3.html?" + "email=" + userEmail + "&testType=" + testType;
    } else if (testType === "bandwidth") {
        //console.log("testtype is bandwidth");
        window.location.href = "evalportalb3.html?" + "email=" + userEmail + "&testType=" + testType;
    } else {
        alert("Please pick a valid Option");
    }
    return false;
}

My 2nd page has two radio buttons that determine if VoIP or Bandwidth and a text field for Email. When I go to the 3rd page I see the values in the URL as expected. But, when I submit a duration I only get the Duration in the URL and not the email or the testType.

I have 5 more pages that I want the parameters to build up over.

html:

<!DOCTYPE html>
<html lang="en">
    <head>
    </head>
    <body>
        <form id="myForm" onsubmit="goPFour(event)" method="get">
            <div id="pBFContainer" class="container">
                <div id="bodyFOption1">
                    <label for="testTime">How long would you like the VoIP test to run?<p></label>
                    <input type="radio" class="testD" name="testTime" value="10" checked/>10 Seconds
                    <input type="radio" class="testD" name="testTime" value="20" />20 Seconds
                </div>
            </div>
            <input type="submit" id="subButton" value="Next..." />
        </form>
    </body>
    <script type="text/javascript" src="evalportalp1.js"></script>
</html>

JS:

function goPFour(event) {   
    event.preventDefault();
    const formData = new FormData(event.target);
    const userEmail = formData.get("email");
    const testType = formData.get("testType");
    const testTime = formData.get("testTime")

    if (testTime === "10") {
        //console.log("testTime is 10");
        window.location.href = "evalportalv4.html?" + "email=" + userEmail + "&testType=" + testType + "&testTime=" + testTime;
    } else if (testTime === "20") {
        //console.log("testTime is 20");
        window.location.href = "evalportalv4.html?" + "email=" + userEmail + "&testType=" + testType + "&testTime=" + testTime;
    } else {
        alert("Please pick a valid Option");
    }
    return false;
}
function goPThree(event) {  
    event.preventDefault();
    const formData = new FormData(event.target);
    const userEmail = formData.get("email");
    const testType = formData.get("testType");

    if (testType === "voip") {
        //console.log("testtype is voip");
        window.location.href = "evalportalv3.html?" + "email=" + userEmail + "&testType=" + testType;
    } else if (testType === "bandwidth") {
        //console.log("testtype is bandwidth");
        window.location.href = "evalportalb3.html?" + "email=" + userEmail + "&testType=" + testType;
    } else {
        alert("Please pick a valid Option");
    }
    return false;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

柒夜笙歌凉 2025-02-17 07:30:46

也许是因为您的两个广播按钮具有相同的名称
“测试时间”?
也许您的HTML中没有“ TestType”。

你怎么认为?

Maybe because your 2 radio buttons have the same name
"testTime"?
or maybe there is no "testType" in your HTML.

what do you think?

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