dongye8110 2017-10-16 19:57
浏览 23
已采纳

是否可以从动态HTML表中读取值并将其传递给输入表单? [关闭]

I'm using on WordPress an amazing tablepress plugin and I have a table on one page that I want to read and pass the value of the table to an input form. The table is the result of a search and will be always a row and a column, just one number. There is any way to do that with PHP or javascript? Or any other way?

I will share some code of the result in the page...

Thanks in advance!

<table id="tablepress-1" class="tablepress tablepress-id-1">
<tbody>
<tr class="row-1">
    <td class="column-1">319</td>
</tr>
</tbody>
</table>
  • 写回答

1条回答 默认 最新

  • dongrui6787 2017-10-16 20:04
    关注

    You probably have jquery available...if so:

    var fromTable = $("#tablepress-1 tr td").text() will give you the value you want.

    You can do something similar to put it into your form:

    $("#myInputField").text(fromTable)

    And if you don't have jQuery, but you KNOW the tables you can get the value like this:

    var fromTable = document.getElementById("tablepress-1").rows[0].cells[0].inn‌​erText

    (Consider all of this pseudo-code and fix it up to suit your situation. The debugger is your friend!)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大