我想在另一个函数中使用在一个函数中传递的参数。如果有可能的话,任何人都可以帮助我
function getByID(UserID) {
$.ajax({
url: "/User/GetByID/" + UserID,
type: "Get",
contentType: "application/json;charset=UTF-8",
dataType: "json",
success: function (result) {
debugger;
$('#Username').val(result.Username);
$('#Email').val(result.Email);
$('#roleName').val(result.RoleID);
},
error: function (errormessage) {
alert(errormessage.responseText);
}
})
return UserID;
};
我想在另一个函数中使用“UserID参数”,如:
$('#modalEdit').on('click',function() {
var objUpdate = {
//UserID:i want here ,
Username: $('#Username').val(),
Email: $('#Email').val(),
RoleID: $('#roleName').val()
};
下面是我表格的Html视图
<tbody>
@if (!Model.Any())
{
<tr>
No Data Availables
</tr>
}
else
{
foreach (var item in Model.Select((x, i) => new { Data = x, sn = i + 1 }))
{
@Html.HiddenFor(model => item.Data.UserID,new { @class="hiddenUser"})
<tr>
<td>@item.sn</td>
<td> @Html.DisplayFor(modelItem => item.Data.Username,new { @id="Username"})</td>
<td>@Html.DisplayFor(modelItem => item.Data.Email, new { @id = "Email" })</td>
<td>@Html.DisplayFor(modelItem => item.Data.RoleName, new { @id = "Role" })</td>
<td>
<button type="button" id="btnEdit" onclick="return getByID(@item.Data.UserID)" class="btn btn-primary fa fa-edit"
data-target="#editUser"
data-toggle="modal">Edit</button>
</td>
</tr>
}
}
</tbody>
答案 0 :(得分:0)
尝试在按钮sprint="Sprint1"
if sprint in browser.find_element_by_xpath(".//*[@id='content']/div[5]/ul/li/ul/li[2]/ul/li[2]/ul/li[2]/a").text:
print ("Wow")
else:
print ("NotWow")
中设置另一个data-
属性来保存userId。
btnEdit
在您的点击功能
中data-info = "@item.Data.UserID"