Q:

Use getElementById in Alert

This is my code:
<form method="GET">
<input type="text" class="form" name="name" placeholder="Enter your name!" id="name">
<input type="submit" onclick="return clicked();" value="I'm ready!">
</form>
<script>
function clicked() {
 return confirm('Hiya,');
}
var email = document.getElementById('name').value;
</script>

I've had a search around, but I cannot find any single topic which matches my question. On the return confirmation where it currently just says Hiya, I would like it to then also include the name which the user entered into the text input.
Help would be appreciated.

A:

This should do what you want:

<form method="GET">
  <input type="text" class="form" name="name" placeholder="Enter your name!" id="name">
  <input type="submit" onclick="return clicked();" value="I'm ready!">
</form>
<script>
  function clicked() {
    var name = document.getElementById('name').value;


    return confirm('Hiya,' + name);
  }

  var email = document.getElementById('name').value;
</script>

