I have a radio button with specific values that I want to include in my URL parameters for the following pages (more than one). I have the parameters set up in the JS as var params
.
in my, if-statement I have a console.log and location.href set to the next page desired based on the result.
-
my issue is when I press the button it takes me to the page but not with the desired parameters.
-
I also have 5 pages for each result following this page. how can I append the parameters to the following pages?
EPP1.HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Create Custom Evaluation Portal</title>
</head>
<body>
<div id="bodyText"></div>
<form id="myForm" action="EPV3.html" method="get">
<div id="pBFContainer">
<div id="bodyFOption1">
<label for="email">Enter email address:<p></label>
<input type='text' id='inputEmail' name='email' size="70"></input></div>
<div id="bodyFTitle2"></div>
<div id="bodyFOption2">
<label for="testType">Choose the test theme for your evaluation:<p></label>
<input id='rb1' class="optionT" type='radio' name='testType' value='voip' checked>VoIP<p>
<input id='rb2' class="optionT" type='radio' name='testType' value='bandwidth'>Bandwidth<br><br>
</div>
<div id="bodyFTitle3"></div>
<div id="bodyFOption3"></div>
</div>
<input type="submit" id="subButton" value="Next..." />
</form>
</body>
<script type="text/javascript" src="EPP1.js"></script>
</html>
EPP1.js:
window.addEventListener("load", () => {
let qs = decodeURIComponent(location.search.substring(1));
let params = new Map();
let parts = qs.split("&");
parts.forEach((part) => {// i got this from a tutorial and liked it
let key = part.split("=")[0];
let val = part.split("=")[1];
params.set(key, val);
});
if (params.get("testType") == "voip") {
console.log("testtype is voip");
window.location.href = "EvalPortalV3.html";
} else if (params.get("testType") == "bandwidth") {
console.log("testtype is bandwidth");
window.location.href = "EvalPortalB3.html";
}
});