The challenge I'm trying to overcome is to write a webpage that takes values from the URL query string and calls these values onto the webpage.
As an example, I want to produce the numbers 1,2,3,4,5, but I'm only capturing numbers 2,3,4 in the query string. My initial thought was to call IDs, but I haven't found a way that doesn't use IDs in separate paragraphs or header tags.
The only way I could think of doing it was to use document.write to contain them all within the same paragraph, but I've hit a roadblock in that my query strings are not passing through, here's some example code:
URL: example.com/index.html?characterTwo=2?characterThree=3?characterFour=4
<script>
< sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
</script>
<script>
function myFunction() {
<!--capture the string and set as variable-->
var 2 = getUrlParameter('characterTwo');
var 3 = getUrlParameter('characterThree');
var 4 = getUrlParameter('characterFour');
<!--define the variable as an ID-->
document.getElementById("2").innerHTML = 2;
document.getElementById("3").innerHTML = 3;
document.getElementById("4").innerHTML = 4;
x.appendChild(t);
document.body.appendChild(x);
}
<!--print the result as a single paragraph with preceding and proceeding characters-->
document.write("1");
document.write(id="2");
document.write(id="3");
document.write(id="4");
document.write("5");
</script>