您的位置:首页 > Web前端 > JavaScript

javascript 更具button 事件找到当前单元格中的控件并动态赋随机ID

2010-12-07 11:14 357 查看
//用当前时间取随机数

function getNum() {

var now = new Date();

var number = now.getMilliseconds();

var num = now.getFullYear().toString() + now.getMonth().toString() + now.getDay().toString() + now.getHours().toString() + now.getMinutes().toString() + now.getSeconds().toString() + now.getMilliseconds().toString();

return num;

}

function OpenWin(url, e) {

var selectedTr = null;

selectedTr = e.parentNode;

var txtname = "";

var txtid = "";

if (selectedTr != null) {

var str = selectedTr;

var inputs = str.getElementsByTagName("input");

for (var j = 0; j < inputs.length; j++) {

input = inputs[j];

if (input.type == "hidden") {

txtid = getNum();

input.id = txtid;

}

}

txtname = getNum() + "i";

var areatxt = str.getElementsByTagName("textarea");

areatxt[0].id = txtname;

}

var str = "&txtName=" + txtname + "&txtId=" + txtid;

var newwindow = window.open(url + str, null, "toolbar=no,scrollbars=yes,menubar=no, location=no, directories=no,width=680,height=550,top=300,left=300");

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: