【问题标题】:How to send text input through a submit button to a column in a table?如何通过提交按钮将文本输入发送到表中的列?
【发布时间】:2014-08-07 03:26:33
【问题描述】:

我有一个包含 6 列的表格,然后是一个文本框和一个提交按钮。 我正在寻找的是我在文本框中输入的信息将保存在其中一列中(或者就像在当前为空的列中弹出一样)。 我现在不知道如何进行,我一直在谷歌上搜索很多,但都是徒劳的。

我在 jquery 中完成了一些事件,允许在单击列时切换颜色。 (这是针对单页应用程序的(当涉及到数据库等时,我没有使用 php。)。

我将不胜感激!我是 web 开发的新手,因为我只用 C# 编写过代码。

        <div id="table-columns">
            <table class="table">
                <thead>
                    <tr class ="tr-table">
                        <td class="mytd" style="border-top: groove;"></td>
                        <td class="mytd" style="border-top: groove;"></td>
                        <td class="mytd" style="border-top: groove;"></td>
                        <td class="mytd" style="border-top: groove;"></td>
                        <td class="mytd" style="border-top: groove;"></td>
                        <td class="mytd" style="border-top: groove;"></td>
                    </tr>

        <td>
             <input id="Information" type="text" name="Information"/>
        </td>
         <td>
             <input id="ActivateButtonId" type="submit" value="Activate">
        </td>

【问题讨论】:

  • 这看起来像是无效的 html。没有&lt;tr&gt; 最后一组&lt;td&gt; s?
  • 所以您想单击一个按钮并使用input 值更改td 中的文本?
  • 你想把textfield的值放到哪个td里面?

标签: javascript jquery asp.net sql html


【解决方案1】:

Demo

检查一下,

  • 这个sn -p current 保存文本框中的值,在第一列-td:first
  • 要在列中设置值 - &lt;td&gt;,您需要使用 .text().val() 来获取文本框值。

$('#ActivateButtonId').click(function(){
    $('.table tr td:first').text($('input[type="text"]').val());
});

【讨论】:

  • 终于成功了!多年来我一直在研究这个功能!输入出现在第一列中。太感谢了!现在我必须弄清楚如何操作代码,以便输入出现在其他列中。感知其中哪一个是空的。
  • 终于成功了!多年来我一直在研究这个功能!输入出现在第一列中。太感谢了!现在我必须弄清楚如何操作代码,以便输入出现在其他列中。感应其中一个是空的..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-03-27
  • 2020-10-24
  • 2016-05-01
  • 1970-01-01
  • 2012-06-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多