how to access parent window controls from child window

Discussion in 'JavaScript' started by musman007, May 19, 2008.

  1. #1
    hey y'all,

    I am trying to access a control which is a hidden field. from child window. Which I opened with the helpf of ShowModalDialog().
    I have tried this on child window.

    window.opener.document.forms(0).getElementById("Literal1").value = document.forms(0).getElementById("Literal2").value.

    But i am getting an error. window.opener.docoment.forms(0).getElementById(..) is not an object or null.

    Please advise how can I access the value of parent control from child window.


    Thanks in advance.
     
    musman007, May 19, 2008 IP
  2. hotmarket

    hotmarket Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can't use window.operner,but you can use below ideas:
    <script type="text/javascript">
    function openWin(){
    // child windows
    var srcFile = "child.html";
    // windows features
    var winFeatures = "dialogHeight:300px; dialogLeft:200px;";
    // The form id as param
    var obj = getForm;
    // open windows
    window.showModalDialog(srcFile, obj, winFeatures);
    }
    </script>
    <form id="getForm">
    Get value:
    <input type="text" id="getValue" readOnly>
    </form>
    <input type="button" value="open" onClick="openWin()">
    //////
    child html
    /////
    <script type="text/javascript">
    function send(){
    // Get param obj
    var obj = window.dialogArguments;
    // set value
    obj.getValue.value = 'from Child';
    }
    </script>
    <a href="#" onclick="send();">Send</a>
     
    hotmarket, May 19, 2008 IP