opener.document 问题

WBOY
Release: 2016-06-23 13:02:59
Original
1099 people have browsed it

<form  name="xingao"><table>  <tr>    <td>       <input  id="" name="q1" type="text" value=""/>      <input id="wupin_id" type="text" value="1"/>      <!--可用于判断不同的id以添加数据--></td>    <td>	<a href=" javascript:void(0)" onClick="window.open('2.php?lx=1');">导入</a> 		</td>  </tr>    <tr>    <td>       <input  id="" name="q1" type="text" value=""/>      <input id="wupin_id" type="text" value="1"/>      <!--可用于判断不同的id以添加数据--></td>    <td>	<a href=" javascript:void(0)" onClick="window.open('2.php?lx=2');">导入</a> 		</td>  </tr>   </table></form>
Copy after login



2.php内容:

<script> <br />opener.document.xingao.tr[0].q1.value="显示内容"; <br />window.close(); <br /></script>

要求结果:改变第一行的 的值
怎么写?


回复讨论(解决方案)

opener.document.xingao.q1[ $n].value="显示内容";
$n 根据需要赋值,因为你的 q1 有多个,所以要按数组操作

<script src="/js/jquery-1.8.3.js"></script><script type="text/javascript">  function import_goods(node){	var tr_number=jQuery("table").index(jQuery(node).parent().parent());//行数	window.open('2.php?lx='+tr_number)}	</script><form  name="xingao"><table>  <tr>    <td>       <input  id="" name="q1" type="text" value=""/>      <input id="wupin_id" type="text" value="1"/>      <!--可用于判断不同的id以添加数据--></td>    <td>	<a href=" javascript:void(0)" onClick="import_goods(this);">导入</a> 	<a href=" javascript:void(0)" onClick="addProductDetail(this)">添加行</a> 	<a href="javascript:void(0)"    name="deleteHref" id="deleteHref" onClick="delProductDetail(this)" style="display: none">删除</a>		</td>  </tr>    <tr>    <td>       <input  id="" name="q1" type="text" value=""/>      <input id="wupin_id" type="text" value="1"/>      <!--可用于判断不同的id以添加数据--></td>    <td>	<a href=" javascript:void(0)" onClick="import_goods(this);">导入</a> 	<a href=" javascript:void(0)" onClick="addProductDetail(this)">添加行</a> 	<a href="javascript:void(0)"    name="deleteHref" id="deleteHref" onClick="delProductDetail(this)" style="display: none">删除</a>		</td>  </tr>     </table></form>
Copy after login


感谢,可以用,还有个问题 tr_number 怎么获取得到行数,每次都是-1

tr_number = $(node).parents('tr').prevAll().length+1

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template