-3

I am developing a site in HTML (not PHP) and am trying to get url parameters to display on an appointment confirmation page. The appointment confirmation info is successfully passed to the URL parameters. But I can't figure out how to get them to appear on the page.

For example:

?name=John&date=Nov-26&Time=4pm

to appear on the html page as:

Name: John Date: Nov 26 Time: 4pm

I have watched tutorials on youtube, followed instructions and copied code from examples on stackoverflow, but the results are a complete failure. Nothing appears on the pages at all.

If you reply, could you please provide the full code as I do do not know javascript and its exceedingly difficult for me to try to figure out where added options get inserted into any base coding you provide. For instance, if there is code with "var" in the option, does that replace the "var" that is in the base code offered, or does it get added to it? If it gets added to it, where does it go? Does it go after the semi-colon, or do I need to start a new curly bracket after the closed curly bracket?

Thanks in advance.

vtnh
  • 1
  • 1
  • 1
    And with your second part question: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics – Justinas Sep 23 '20 at 14:13
  • Welcome to Stack Overflow! Please visit the [help], take the [tour] to see what and [ask]. Do some research, search for related topics on SO; if you get stuck, post a [mcve] of your attempt, noting input and expected output using the `[<>]` snippet editor. - I have this time indulged you and posted an answer that will be voted down BECAUSE you showed no effort. Next time try harder OK? – mplungjan Sep 23 '20 at 14:19
  • So did the answer help you? – mplungjan Sep 23 '20 at 18:34

1 Answers1

-1

Try this - I am using URLSearchParams to extract the values from the URL and template literals to create the string

Change "?name=John&date=Nov-26&Time=4pm" to location.search on your site

<footer id="footer"></footer>


<script>
const srch = "?name=John&date=Nov-26&Time=4pm"; // location.search; 
const parms = new URLSearchParams(srch);
document.getElementById("footer").innerHTML += `Name: <span id="name">${parms.get("name")}</span> 
 Date: <span id="date">${parms.get("date").replace(/-/g," ")}</span> 
 Time: <span id="time">${parms.get("Time")}</span>`;
</script> 
mplungjan
  • 169,008
  • 28
  • 173
  • 236