<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 有没有取到值,如果取到了这样赋值对不对?

解决方案 »

  1.   

    加个id="word"
    <input type="txt" name="word" value= <%=session("wrod")%>>
      

  2.   

    谢谢楼上的 这个id="word"  肯定要加,但是还是不对
    var txtword=document.getElementById("word").value; 
     我认为可以得到 
    但是 不能赋值 到 下面红色的对象里,我认为不是这样赋值;大家看看怎么写。
    window.opener.AddPro.txtword.focus(); 
    window.opener.document.AddPro.txtword.value=imagePath; 
      

  3.   

    错误提示  window.opener.AddPro.txtword  为空或不是对象
      

  4.   

    window.opener.AddPro.txtword.focus(); 
    window.opener.document.AddPro.txtword.value=imagePath; 楼主这不是自相矛盾嘛
      

  5.   

    谢谢楼上的  这个不是错误的根源, 
    关键是  var txtword=document.getElementById("word").value;   的值
    无法赋值到 下面的 txtword 里
    window.opener.AddPro.txtword.focus(); 
    window.opener.document.AddPro..txtword.value=imagePath; 
    谢谢。麻烦朋友们看仔细。给个正确答案
      

  6.   

    看了半天,终于有些明白了window.opener.document.AddPro[txtword].value=imagePath;
    window.opener.document.getElementById(txtword).value=imagePath;你要把txtword用"名称"代入试试
    显然....AddPro."名称".focus();肯定不通过
      

  7.   

    赋值前LZ用window.opener.AddPro.txtword.focus(); 将焦点移到这个地方没必要吧直接赋值:只要对象window.opener.document.AddPro存在就可以  window.opener.document.AddPro.txtword.value=imagePath;这样赋值,这行上面的一行去掉
      

  8.   

    设A.aspx为父窗口。
    设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上去了。