<script type= "Text/javascript" language= "JavaScript" >
Block Browser Right-click
function Stop () {
return false;
}
Document.oncontextmenu = stop;
var i=3;
$ (function () {
Click on the page other location right-click menu disappears
$ (' body '). Bind (' click ', function (EV) {
$ (' #menu '). CSS (' Display ', ' none ');
$ (' #menub '). CSS (' Display ', ' none ');
});
var $inp = $ ('. CLS ');
$inp. Bind (' KeyDown ', function (e) {
var key = E.which;
if (key = = 13) {
var id = $ ("Input:focus"). attr ("id");
if (id = = "isAbroad2") {
AddTable ();
document.getElementById ("Name3"). focus ();
}
E.preventdefault ();
var nxtidx = $inp. Index (this) + 1;
$ (". Cls:eq (" + Nxtidx + ")"). focus ();
}
});
echo Child table 1 data
var b=$ ("#dcasXmsbs_2_1s"). Val ();
if (b!=null && b!= "") {
var c=b+ "";
var d=c.replace (/__/g, ' "');
var e=d+ "";
var json=eval (' (' +e+ ') ');
if (json.length<1) {
}else{
for (var s = 0; s < json.length; s++) {
if (s>2) {
AddTable ();
}
$ ("#id" +s). Val (json[s].id);
$ ("#name" +s). Val (Json[s].name);
$ ("#birthday" +s). Val (Json[s].birthday);
$ ("#nationality" +s). Val (json[s].nationality);
$ ("#education" +s). Val (json[s].education);
$ ("#duty" +s). Val (json[s].duty);
$ ("#studyDirection" +s). Val (json[s].studydirection);
$ ("#plan" +s). Val (Json[s].plan);
$ ("#isAbroad" +s). Val (json[s].isabroad);
}
i = json.length;
}
}
});
Additional details
function addtable () {
var s = i+1;
var tbody= "tbody" + i;
var id = "id" + i;
var name = "Name" + i;
var birthday = "Birthday" + i;
var nationality = "nationality" + I;
var education = "Education" + I;
var duty = "Duty" + I;
var studydirection = "Studydirection" + i;
var plan = "plan" + i;
var isabroad = "Isabroad" + i;
$ ("#table_buffer")
. Append (
"<tbody id=\" "+tbody+" \ "class= ' Pn-ltbody ' >"
+ "<td>" + "<input type=\" hidden\ "id=\" "+id+" \ "name=\" "+id+" \ "/>" + "<input type=\" text\ "id=\" "+name+" \ "Name=\" "+name+" \ "style=\" width:80px;\ "onmouseup=\" Youjian ("+s+", this) \ "/>" + "</td>"
+ "</tbody>");
i++;
$ ("#countInfo1"). Val (i);
}
function Changenextfocus (str, s,event) {
if (Event.keycode = = 13) {
if (str = = "Netline") {
AddTable ();
var SS = s + 1;
document.getElementById ("name" + ss). focus ();
} else {
Str.focus ();
}
}
}
Table 1
Right-click event
var RowIndex; Used to delete data in the background
Var rowindex2;//identifies when forward
function Youjian (A, b) {
var container = document.getElementById (' Table_buffer ');
var menu = document.getElementById (' menu ');
if (Event.button = = 2) {
var evt = window.event | | Arguments[0];
/* Gets the current position of the right mouse button, which defines where the menu is displayed */
Menu.style.left = container.scrollleft + evt.clientx + "px";
Menu.style.top = container.scrolltop + evt.clienty +document.body.scrolltop+ "px";
/* Settings menu Visible */
$ (' #menu '). CSS (' Display ', ' block ');
RowIndex = A;
RowIndex2 = b;
}
}
Delete Row
function Delrow () {
var r = rowIndex-1;
var delId1 = $ (' #delId1 '). Val ();
if (Delid1==null | | delId1 = = "") {
var id = $ ("#id" +r). Val ();
$ (' #delId1 '). val (id);
}else{
$ (' #delId1 '). Val (delid1+ "," +$ ("#id" +r). Val ());
}
document.getElementById (' Table_buffer '). DeleteRow (RowIndex2.parentNode.parentNode.rowIndex);
}
</script>
<body>
<div id= "Menu" class= "Menuskin" >
<span style= "cursor:pointer;" id= "Shanchu" onclick= "Delrow ()" > Delete </span>
</div>
</body>
JS Enter dynamic Add table, right-click to dynamically delete table row