求a 并将其检索到输入框中
本文关键字:检索 输入 TD | 更新日期: 2023-09-27 18:08:50
我有一些麻烦得到文本在a和把它放在一个框,在这里你可以找到一个小的例子。这个想法是当用户点击"选择"时它会把代码从
<td> @Html.DisplayFor(Mod => Item.Item.Custumer_code) <td/>
中的Input输入带有customercode ID。下面是代码:
<div class="col-sm-3">
<input class="form-control"
placeholder="Entre a custumer code"
id="Custumercode"
name="Custumercode"/>
</div>
<table class="table">
<thead>
<tr>
<th>Costumer Code</th>
<th>Select</th>
<th>Costumer Name</th>
<th>Email </th>
<th>Tel </th>
</tr>
</thead>
@foreach (var Item in Model)
{
<tbody>
<tr>
<td> @Html.DisplayFor(Mod => Item.Custumer_code) </td>
<td> @Html.DisplayFor(Mod => Item.custumer_name) </td>
<td> @Html.DisplayFor(Mod => Item.Email) </td>
<td> @Html.DisplayFor(Mod => Item.Tel) </td>
<td>
<button type="button" class="btn" onclick="myFunction()">
Select
</button>
</td>
</tr>
</tbody>
}
</table>`
试试这个
$(document).ready(function(){
$(document).on('click','.btn',function(){
var customer = $(this).parents('tr').find('td:eq(0)').text();
$('#Custumercode').val(customer );
});
});
演示
试试这个:
$(document).ready(function(){
$('.btn').click(function(){
var customerCode = $(this).closest('tr').find('td:nth-child(1)').text();
$('#Custumercode').val(customerCode );
});
});
相关文章:
- 更好/有效的方法来检查用户 url 输入
- 从 Windows/Windows Phone 8.1 中的 WebView HTML 中检索内部文本
- 有没有办法以编程方式绑定到输入绑定命令属性
- 使用 LINQ 从 XDocument 检索嵌套列表
- 如何在 Windows 窗体应用程序中更改特定控件的输入语言
- 输入字符串的格式不正确,无法检索 GridView 值
- 如何从文本框数组中检索输入的文本
- 简化将输入检索到数组的过程
- 如何从函数中检索输入
- 检索ItemDataBound中的RadGrid单元格值-“;输入字符串的格式不正确&”;
- 如何使用jQuery从表中检索td输入的文本框值
- SQL-根据用户输入的值从两个相关表中检索数据
- 在ASP.NET中命名组输入和检索控制器中的值
- 在网格视图中动态添加控件并检索用户在Asp.net中输入的值
- 从asp.net自定义web控件检索输入值
- 求a
并将其检索到输入框中
- 无法检索用户的TextBox输入
- 哪个泛型适合以与输入顺序相反的顺序检索自定义数据类型
- 使用url的json输入,反序列化为c&;从web API检索值
- 为什么我收到“;输入字符串的格式不正确”;检索Gridview行索引时
本文关键字:检索 输入 TD | 更新日期: 2023-09-27 18:08:50
我有一些麻烦得到文本在a和把它放在一个框,在这里你可以找到一个小的例子。这个想法是当用户点击"选择"时它会把代码从
<td> @Html.DisplayFor(Mod => Item.Item.Custumer_code) <td/>
中的Input输入带有customercode ID。下面是代码:
<div class="col-sm-3">
<input class="form-control"
placeholder="Entre a custumer code"
id="Custumercode"
name="Custumercode"/>
</div>
<table class="table">
<thead>
<tr>
<th>Costumer Code</th>
<th>Select</th>
<th>Costumer Name</th>
<th>Email </th>
<th>Tel </th>
</tr>
</thead>
@foreach (var Item in Model)
{
<tbody>
<tr>
<td> @Html.DisplayFor(Mod => Item.Custumer_code) </td>
<td> @Html.DisplayFor(Mod => Item.custumer_name) </td>
<td> @Html.DisplayFor(Mod => Item.Email) </td>
<td> @Html.DisplayFor(Mod => Item.Tel) </td>
<td>
<button type="button" class="btn" onclick="myFunction()">
Select
</button>
</td>
</tr>
</tbody>
}
</table>`
试试这个
$(document).ready(function(){
$(document).on('click','.btn',function(){
var customer = $(this).parents('tr').find('td:eq(0)').text();
$('#Custumercode').val(customer );
});
});
演示试试这个:
$(document).ready(function(){
$('.btn').click(function(){
var customerCode = $(this).closest('tr').find('td:nth-child(1)').text();
$('#Custumercode').val(customerCode );
});
});
相关文章:
- 更好/有效的方法来检查用户 url 输入
- 从 Windows/Windows Phone 8.1 中的 WebView HTML 中检索内部文本
- 有没有办法以编程方式绑定到输入绑定命令属性
- 使用 LINQ 从 XDocument 检索嵌套列表
- 如何在 Windows 窗体应用程序中更改特定控件的输入语言
- 输入字符串的格式不正确,无法检索 GridView 值
- 如何从文本框数组中检索输入的文本
- 简化将输入检索到数组的过程
- 如何从函数中检索输入
- 检索ItemDataBound中的RadGrid单元格值-“;输入字符串的格式不正确&”;
- 如何使用jQuery从表中检索td输入的文本框值
- SQL-根据用户输入的值从两个相关表中检索数据
- 在ASP.NET中命名组输入和检索控制器中的值
- 在网格视图中动态添加控件并检索用户在Asp.net中输入的值
- 从asp.net自定义web控件检索输入值
- 求a
并将其检索到输入框中 - 无法检索用户的TextBox输入
- 哪个泛型适合以与输入顺序相反的顺序检索自定义数据类型
- 使用url的json输入,反序列化为c&;从web API检索值
- 为什么我收到“;输入字符串的格式不正确”;检索Gridview行索引时