单击按钮后将php td值插入文本区域

单击按钮后将php td值插入文本区域,php,jquery,Php,Jquery,我有一个带有3个tds的echo PHP表: 1-复选框。 2-姓名。 3-电话号码 我让textarea包含所有选中的复选框tds电话号码 我喜欢,但我不喜欢 我的代码: <table class="table table-striped table-bordered TableStyle" id="table-scroll "> <thead> <th class="thead"><input type="checkbox"

我有一个带有3个tds的echo PHP表: 1-复选框。 2-姓名。 3-电话号码

我让textarea包含所有选中的复选框tds电话号码

我喜欢,但我不喜欢

我的代码:

<table class="table table-striped table-bordered TableStyle" id="table-scroll ">
    <thead>
        <th class="thead"><input type="checkbox" name="checkallnum" value="" id="checkallnum2" /></th>
        <th class="thead">Name</th>
        <th class="thead">Phone</th>
    </thead>
    <tbody>
        <tr>
             <td><input class="checkBoxClass" type="checkbox" name="check" value="" /></td>
             <td>AMMAR</td>
             <td>123456789</td>
        </tr>
         <tr>
             <td><input class="checkBoxClass" type="checkbox" name="check" value="" /></td>
             <td>Sara</td>
             <td>987654321</td>
        </tr>
    </tbody>
 </table>

<button type="button" id="confirmNums" class="btn btn-primary pull-left" style="">Add</button>

<textarea rows="8" name="" id="sendToNum" class="form-control" style="margin-bottom: 10px;" tabindex="1"></textarea>

名称
电话
安马尔
123456789
萨拉人
987654321
添加

一种可能的解决方案是使用jQuery

也许这个例子可以让你开始。当您单击“添加”按钮时,电话号码将添加到文本区域

$(文档).ready(函数(){
$('#confirmNums')。单击(函数(){
var newline=“\n”;
变量sendToNum=$(“#sendToNum”);
sendToNum.text(“”);
$(“输入[名称=检查]:已检查”)。每个(函数(){
var phoneNumber=$(this.parent().nextAll('td').eq(1.html();
追加(电话号码+换行符);
});
});
});

名称
电话
安马尔
123456789
萨拉人
987654321
添加

这是一种非常有效的方法。但我需要的是添加这个添加点击功能。因此,请先选中,然后单击以添加数字。谢谢你的帮助help@ammoriz好吧,我明白你的意思了。我已经更新了代码。如果按“添加”按钮,电话号码将添加到文本区域。