I'm newbie in JS and trying to show a alert box when user enters his/her "name-mail-message" in my html page. That alert box should contain information given by user. This is what I did;
<button type="submit" onclick="test()" class="form-control" id="submit-button" name="submit">Send</button>
<script type="text/javascript">
function test() {
let inputName = document.getElementById("cf-name");
let inputMail = document.getElementById("cf-mail");
let inputMessage = document.getElementById("cf-message");
let total = (inputName.value);
alert(inputName.value + '\n' + inputMessage.value);
}
</script>
When I run it I get this output.
How can I fix this issue? If you can help I would be appreciated.