2016-03-15 90 views
-1

我有一個html輸入表單,它使用一個3列的表格來正確對齊HTML控件。輸入數據用於生成MySQL查詢。在列1中有幫助用戶理解第2列中的控件的含義的文本。在第2列有下拉列表或文本輸入。在列3有提交按鈕和幫助按鈕(不相關)。通過JavaScript輸入表格中的動態文本

<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> 

我的問題是:如何通過JavaScript更改文本在列1(小寫行)根據用戶輸入(上部行)?我可以在JavaScript DOM中引用表格的單元格嗎?要麼... ?

+0

可能使用jQuery? –

+1

使用像Praveen建議的任何JavaScript框架。 https://jquery.com/ 你必須在你的文檔中包含JavaScript,然後你可以添加和id到你想要更改的元素,然後可以訪問$(「#you_id」)。html(「新內容「) 例如。 – satchcoder

+0

你可以創建[jsFiddle](https://jsfiddle.net/)嗎? –

回答

0

這是解決我的問題:span tags and Javascript 您在span標籤

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

,然後你可以在JavaScript中改變它封閉的文本。

相關問題