首页 > 代码库 > js模态窗口返回值(table)
js模态窗口返回值(table)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function btnOpen_Click()
{
var obj=window.showModalDialog("Noname2.html",window);
document.getElementById("brandId").value=http://www.mamicode.com/obj[0];
document.getElementById("brandName").value=http://www.mamicode.com/obj[1];
alert(obj[0]);
alert(obj[1]);
}
</script>
</head>
<body>
<input id="brandId" type="hidden" name="brandId" value="" style="width:80"/>
<input id="brandName" type="text" name="brandName" value="" style="width:80" onclick="btnOpen_Click();" />
<br/>
</body>
</html>
-----Noname2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
/*function test(obj){
var td1 = obj.firstElementChild.firstChild.value;
var td2=obj.lastElementChild.firstChild.value;
var array=new Array();
array.push(td1);
array.push(td2);
window.returnValue=http://www.mamicode.com/array;
window.close();
}*/
function test(obj){
var td1 = obj.firstElementChild.firstChild.innerHTML;
var td2=obj.lastElementChild.firstChild.innerHTML;
var array=new Array();
array.push(td1);
array.push(td2);
window.returnValue=http://www.mamicode.com/array;
window.close();
}
</script>
</head>
<body >
<!--form name = "Form2">
<input type = "button" value="http://www.mamicode.com/Click" name = "btnOpen" onClick="btnOpen_Click();" />
<input id="bbbbb" type = "text" name = "txtValue" />
</form-->
<!--table border="1" id="table">
<tr>
<td><input name="" id="" value="http://www.mamicode.com/序号" /></td>
<td><input name="" id="" value="http://www.mamicode.com/数量" /></td>
</tr>
<tr ondblclick="test(this)" id="1">
<td><input name="" id="" value="http://www.mamicode.com/1" /></td>
<td><input name="" id="" value="http://www.mamicode.com/2" /></td>
</tr>
<tr ondblclick="test(this)" id="2">
<td><input name="" id="" value="http://www.mamicode.com/3" /></td>
<td><input name="" id="" value="http://www.mamicode.com/4" /></td>
</tr>
<tr ondblclick="test(this)" id="3">
<td><input name="" id="" value="http://www.mamicode.com/5" /></td>
<td><input name="" id="" value="http://www.mamicode.com/6" /></td>
</tr>
</table-->
<table border="1" id="table">
<tr>
<td><input name="" id="" value="http://www.mamicode.com/序号" /></td>
<td><input name="" id="" value="http://www.mamicode.com/数量" /></td>
</tr>
<tr ondblclick="test(this)" id="1">
<td><div>1</div></td>
<td><div>2</div></td>
</tr>
<tr ondblclick="test(this)" id="2">
<td><div>3</div></td>
<td><div>4</div></td>
</tr>
<tr ondblclick="test(this)" id="3">
<td><div>5</div></td>
<td><div>6</div></td>
</tr>
</table>
</body>
</html>
js模态窗口返回值(table)