简体   繁体   English

通过 JavaScript 输入表单中的动态文本

[英]Dynamic text in input form through JavaScript

I have a html input form which uses a table with 3 columns for proper alignment of HTML controls.我有一个 html 输入表单,它使用一个包含 3 列的表格来正确对齐 HTML 控件。 The input data is used to generate a MySQL query.输入数据用于生成 MySQL 查询。 In column 1 there is text which helps the user understand what the controls in column 2 mean.1 列中的文本可帮助用户了解第 2 列中的控件的含义。 In column 2 there are dropdownlists or text input.在第2 列中有下拉列表或文本输入。 In column 3 there is the submit button and a help button (not relevant).在第3 列中有提交按钮和帮助按钮(不相关)。

<div class="input_frm">
  <form method="post" action="<?php print data_clean($_SERVER["PHP_SELF"]);?>">
    <table class="input_tbl">
       <tr>
          <td class="a">Select province</td>
          <td class="b"><select id="selProvincie" name="Alfa" onchange="ProvincieChg()"></select></td>
          <td class="c"><input class="button_face" type="submit" value="Submit"></td>
          </tr>
       <tr>
          <td class="a">Select region</td>
          <td class="b"><select id="selRegiune" name="Beta" onchange="RegiuneChg()"></select></td>
          <td class="c"></td>
          </tr>
...
       </table>
    </form>
  </div>

My question is: How can I change the text in column 1 (in lower rows) through JavaScript based on user input (in upper rows) ?我的问题是:如何根据用户输入(上排)通过 JavaScript 更改第1 列(下排)中的文本? Can I reference the cells of the table in the JavaScript DOM ?我可以在 JavaScript DOM 中引用表格的单元格吗? Or... ?或者... ?

Here is the solution to my question: span tags and Javascript You enclose the text in span tags这是我的问题的解决方案: span 标签和 Javascript您将文本括在span 标签中

<td><span class="aa">This text can be changed in Javascript</span></td>

and then you can change it in JavaScript.然后你可以在 JavaScript 中更改它。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM