I'm trying to figure out how to get javascript to display values entered into a form element.
I may be doing this wrong from the outset and this is not the standard way to do it but here is what I'm working with.
HTML
<form>
First name: <input type= "text" id="firstname" name="firstname"> <br> <br>
Last name: <input type= "text" id="lastname" name="lastname" <br> <br> <br>
<input type = "submit" value="submit">
</form>
JavaScript
<script>
function getElementById("firstname"){
var userName= document.getElementById("firstname")
document.write("Hello, " + userName);
</script>
Aucun commentaire:
Enregistrer un commentaire