我有这个javascript函数
function SaveData(index) {
var myVirtualForm = document.createElement("form");
myVirtualForm.setAttribute('method', "post");
var name = $("#" + index + " a").attr('name');
var url = "http://localhost/my_Project/communicator.php?command=save&id=" + name;
myVirtualForm.setAttribute('action', url);
var iframe = document.getElementById(index + "frame");
var innerDoc = iframe.contentDocument || iframe.contentWindow.document;
var oTable = innerDoc.getElementById("reporttable");
//alert(oTable.rows.item(0).cells.item(0).innerText);
//gets table
var str = "";
var rowLength = oTable.rows.length;
//gets rows of table
for (i = 0; i < rowLength; i++) {
//loops through rows
var oCells = oTable.rows.item(i).cells;
var cellLength = oCells.length;
for (var j = 0; j < cellLength; j++) {
var cellVal = oCells.item(j).innerText;
var a = "";
var b = a.concat(i.toString(), "_", j.toString());
var obj = document.createElement("input");
obj.setAttribute('type', "text");
obj.setAttribute('name', b);
obj.setAttribute('value', cellVal.toString())
myVirtualForm.appendChild(obj);
}
}
myVirtualForm.submit();
}
提交后我们去了communicator.php,但我想留在同一页面,谁不会改变。