红色圈的部分是通过后台生成的input标签,并且增加了onclick=\"btnClick()\"事件,然后在前台用js可以获取到你点击的哪一个input标签的id和name:
function btnClick() {
var obj = event.srcElement;
if (obj.type == "button") {
var myid = obj.name;
//alert(myid);
document.getElementById('<%=Label2.ClientID%>').innerHTML = myid;
}
}
但现在问题是我想要后台通过一个点击事件来判断点击的哪一个input的id和name?
这个应该怎样写呢?
希望大神们能帮帮我!
相关问题
- Jasper: error opening input stream from url
- is it normal for image inputs to be omitted from t
- How do I discard user input delivered during sleep
- How to make CSS input range thumb not appear at fi
- R: How can I make a function with a function input
相关文章
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Show a different value from an input that what wil
- Is there a way to hide the new HTML5 spinbox contr
- Programmatically interrupting raw_input
- Bootstrap input field inside tooltip popover remov
- ValueError: too many values to unpack (expected 2)
- customising the look of f.file.field in rails
- Handle IE 9 & 10's clear button with Knockout
点击删除,调用后台的DeleteDate方法,将参数传过去
var msg = "您真的确定要删除吗?\n\n请确认!";
if (confirm(msg) == true) {
document.onclick = function () {
var obj = event.srcElement;
if (obj.type == "button") {
var myid = obj.name;
//alert(myid);
$.ajax({
type: "post",
url: "MyWebForm.aspx/DeleteDate",
data: "{'Id':'" + myid + "'}",
contentType: "application/json",
dataType: "json",
success: function (r) {
//alert(r.d);
window.location.href = window.location.href;
},
error: function (e) {
alert("错误是:" + e.responseText);
}
});
return false;
}
}
}
else {
return false;
}
既然你前端都可以判断点击了谁~那作为参数传递到后端不就完了