我是JS的新手,当用户在我的html页面中输入他/她的“姓名-邮件-消息”时,我会尝试显示一个警告框。该警告框应包含用户提供的信息。这就是我所做的;
<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>当我运行它的时候,我得到了这个输出。

如何解决此问题?如果你能帮上忙,我将不胜感激。
发布于 2021-06-28 14:38:24
只需在警报中传递total变量
alert(total)https://stackoverflow.com/questions/68158586
复制相似问题