简体   繁体   English

如何显示确认提示,显示当用户在文本字段中输入信息并单击js中的“提交”时输入的内容

[英]How to display an acknowledgement prompt showing what has been entered when user inputs info into text fields and clicks submit in js

Was wondering how to display an acknowledgement prompt using javascript when user inputs info into textfields on a form that shows what they have entered eg "Hello 'user' you have entered this comment: 'comment'" 想知道当用户在显示他们输入内容的表单上的文本字段中输入信息时如何使用javascript显示确认提示,例如“您好,'用户',您输入了此注释:'评论'”

Ive been trying using variables and an alert box but haven't been able to get it to work: 我一直在尝试使用变量和警报框,但未能使其正常工作:

    function updateTxt() {
        var content1 = document.getElementById('name').innerText;
        var content2 = document.getElementById('email').innerText;
        var content3 = document.getElementById('comments').innerText;
        var content4 = document.getElementById('rating').value;
           alert("Dear: " + frm.content1.value,"thank you for your  feedback, you rated us "frm.content4.value" and this is your comment: " frm.content3.value) 
  }

(content4 is from a radio button) (content4来自单选按钮)

This is the form code with a validation function and the submit button code: 这是带有验证功能和提交按钮代码的表单代码:

     <form name="Feedback" action="#"onsubmit="return validateForm()" method="post">

     <input type="submit" onclick="updateTxt()" value="Submit">

Just looking for pointers to see if I've missed anything, thanks in advance 只是寻找指针,看看我是否错过了任何东西,在此先感谢

You're missing some + 's in your alert. 您的警报中缺少+ Also I'm not sure what frm is, but you shouldn't need to reference it based on the example. 另外,我不确定frm是什么,但是您无需根据示例引用它。

function updateTxt() {
  var content1 = document.getElementById('name').innerText;
  var content2 = document.getElementById('email').innerText;
  var content3 = document.getElementById('comments').innerText;
  var content4 = document.getElementById('rating').value;
  alert("Dear: " + content1 + ", thank you for your feedback, you rated us " + content4 + " and this is your comment: " + content3) 
}

Working jsFiddle 工作jsFiddle

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当用户将电子邮件放入文本字​​段并单击提交时,如何控制发生的情况 - How to control what happens when a user puts their email in the text field and clicks submit Javascript提醒用户已经输入了相同的信息 - Javascript to alert a user that the same info has already been entered 在react js中单击提交后如何显示用户信息 - how to display user info after clicked submit in react js 用户从容器中单击时提交一组输入 - submit group of inputs when user clicks out of container 用户单击任何链接时显示文本 - Display text when user clicks on any link 在用户输入此文本并点击提交后,如何显示带有文本的新 div? - How can I display a new div with text after a user inputs this text and hits submit? 用户单击提交时如何在图表中显示计算结果? - How can I display calculated results in a graph when user clicks submit? 执行 while 循环 - 我只想在用户在提示中输入 1 或 2 或在提示中选择取消时退出此循环 - Do while Loop - I only want to exit this loop when user has entered 1 or 2 into the prompt or selects the cancel in prompt HTML如何在用户单击句子时提示消息框 - HTML How to prompt a Message Box when the User clicks a sentence 如何在模式中使用从 handleSubmit 函数返回的数据来显示用户输入的内容? - How do I use the data returned from a handleSubmit function in a modal to display what the user has entered?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM