<script language="JavaScript">
<!--
function Addpic(imagePath){
var txtword=document.getElementById("word").value;
window.opener.AddPro.txtword.focus();
window.opener.document.AddPro.txtword.value=imagePath;
window.opener=null;
window.close();
}
//-->
</script>
就是如何让 txtword 赋值到下面的语句,就是不行.我直接写表单元素就有效,为什么?
问题补充:AddPro 是父窗口的FORM 名称,我这里是要把imagePath,返回到父窗口的元素中.谢谢大家!
楼下三位朋友 的答案都不对,试过了!
这是word值,可以任意 <input type="txt" name="word" value=<%=session("wrod")%>>,关键是txtword 有没有取到值,如果取到了这样赋值对不对?
<!--
function Addpic(imagePath){
var txtword=document.getElementById("word").value;
window.opener.AddPro.txtword.focus();
window.opener.document.AddPro.txtword.value=imagePath;
window.opener=null;
window.close();
}
//-->
</script>
就是如何让 txtword 赋值到下面的语句,就是不行.我直接写表单元素就有效,为什么?
问题补充:AddPro 是父窗口的FORM 名称,我这里是要把imagePath,返回到父窗口的元素中.谢谢大家!
楼下三位朋友 的答案都不对,试过了!
这是word值,可以任意 <input type="txt" name="word" value=<%=session("wrod")%>>,关键是txtword 有没有取到值,如果取到了这样赋值对不对?
<input type="txt" name="word" value= <%=session("wrod")%>>
var txtword=document.getElementById("word").value;
我认为可以得到
但是 不能赋值 到 下面红色的对象里,我认为不是这样赋值;大家看看怎么写。
window.opener.AddPro.txtword.focus();
window.opener.document.AddPro.txtword.value=imagePath;
window.opener.document.AddPro.txtword.value=imagePath; 楼主这不是自相矛盾嘛
关键是 var txtword=document.getElementById("word").value; 的值
无法赋值到 下面的 txtword 里
window.opener.AddPro.txtword.focus();
window.opener.document.AddPro..txtword.value=imagePath;
谢谢。麻烦朋友们看仔细。给个正确答案
window.opener.document.getElementById(txtword).value=imagePath;你要把txtword用"名称"代入试试
显然....AddPro."名称".focus();肯定不通过
设B.axpx为子窗口。设:A.aspx 有个textbox id=txtword
A页面调用的JS<script type ="text/javascript" >
function go()
{
var tourl="B.aspx";
var url,strReturn;
strReturn=window.showModalDialog(tourl,'','dialogHeight=580px; dialogWidth=800px;help=no;scroll=yes;status:no;');
if(strReturn)
{
document.getElementById ("txtword").value=strReturn;//传回的imagePath
}
}
</script>
B.aspx页面的JS <script type="text/javascript">
function Addpic(imagePath)
{
window.returnValue=imagePath; //imagePath
window.close();
}
</script>这样,从子窗口,返回的imagePath,传递到,父窗口的txtbox上去了。