简体   繁体   English

如何在JavaScript中显示html文本字段的内容?

[英]How to display the contents of an html text field in JavaScript?

Revised Question: How can you display the text entered into an html text field in JavaScript? 修订的问题:如何显示在JavaScript中输入html文本字段的文本?

https://jsfiddle.net/bjc7em1w/ https://jsfiddle.net/bjc7em1w/

<tr>
  <td id="number1"> (1)</td>  
  <td> <input type="radio" name="radio1" id="standardA1"> </td> 
  <td> <input type="radio" name="radio1" id="standardI1"> </td> 
  <td id="standard1">Describe the reason for the development of 
                     the plan and its annexes.</td>
   <td> <input type="text" id="comments1"> </td>     
</tr>

Since the discription of the problem was rather confusing to read, I will answer just the question: 由于问题的描述非常难以理解,因此我将仅回答以下问题:

var text = document.querySelector("#textbox").value;
alert("The textbox value is: " + text);

If you have any questions about this or want me to elaborate please say so. 如果您对此有任何疑问或希望我详细说明,请这么说。

If I understand correctly, you are looking to add feedback messages related to your form. 如果我理解正确,那么您正在寻求添加与您的表格相关的反馈消息。 You can add an empty span tag to the section where you want the message to display and call it on blur. 您可以在要显示消息的部分添加一个空的span标签,并在模糊时调用它。

For example, add something like: 例如,添加如下内容:

<tr>
    <td id="number1"> (1)</td>  
    <td> <input type="radio" name="radio1" id="standardA1"> </td> 
    <td> <input type="radio" name="radio1" id="standardI1"> </td> 
    <td id="standard1">Describe the reason for the development of the 
                       plan and its annexes.</td>
    <td> <input type="text" id="comments1" onblur="message()"> 
         <span class="message" id="message"></span>
    </td>     
</tr>

When the user leaves the section calling onblur, the message can be called like this: 当用户离开调用onblur的部分时,可以像这样调用消息:

function message() { 
   document.getElementById("message").innerHTML = "message written here";
}

You can add functionality to determine when and how the message is shown. 您可以添加功能来确定何时以及如何显示消息。

暂无
暂无

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

相关问题 HTML/Javascript - 如何将输入字段中的文本显示为 HTML 代码? - HTML/Javascript - How to display text from input field as HTML code? 如何用多行文本显示从JavaScript到HTML的文本 - How to display text with multiline from JavaScript to the HTML 如何使用JavaScript在HTML中显示文本文件中的文本 - How to display text from a textfile in html with javascript 如何将文本区域的内容发送到Typescript / Javascript / HTML中的函数 - How to send the contents of a text area to a function in Typescript / Javascript / Html 如何使用Javascript和HTML 5按名称加载本地文本文件的内容? - How to load the contents of a local text file by name using Javascript and HTML 5? 如何在HTML或JavaScript中显示目标C中的数组,如何在按钮上显示数组的内容 - How to display the array which is in objective C to the HTML or JavaScript,to display the contents of array on a buttonclick in HTML 无法在 html 网页中显示文本文件的内容 - Unable to display the contents of a text file in an html webpage javascript文本字段计数器显示 - javascript text field counter display 如何使用 JavaScript 显示 html 输入:.html(&#39; &lt; input type=&quot;text&quot; /&gt;&#39;) - How to display a html input using JavaScript : .html(' < input type="text" />') 如何在 HTML 和 Javascript 的动态列表中显示格式化的 HTML 文本 - How to display formatted HTML text in dynamic list in HTML and Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM