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=obj[0];
document.getElementById("brandName").value=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=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=array;
window.close();
}

</script>
</head>

<body > 

<!--form name = "Form2">
<input type = "button" value="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="序号" /></td>
<td><input name="" id="" value="数量" /></td>
</tr>
<tr ondblclick="test(this)" id="1">
<td><input name="" id="" value="1" /></td>
<td><input name="" id="" value="2" /></td>
</tr>
<tr ondblclick="test(this)" id="2">
<td><input name="" id="" value="3" /></td>
<td><input name="" id="" value="4" /></td>
</tr>
<tr ondblclick="test(this)" id="3">
<td><input name="" id="" value="5" /></td>
<td><input name="" id="" value="6" /></td>
</tr>
</table-->


<table border="1" id="table">
<tr>
<td><input name="" id="" value="序号" /></td>
<td><input name="" id="" value="数量" /></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>

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。