JS广播按钮值仅显示第二页,但不显示第三页
我的第二页有两个无线电按钮,可以确定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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许是因为您的两个广播按钮具有相同的名称
“测试时间”?
也许您的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?