object undefined - problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • s_m_b

    object undefined - problem

    here's the code (running from an ASP page):
    <script language = "JavaScript " type="text/javascript">
    function initStuff() {
    var scanWindow = window.open('sc anning.htm', 'scanning',
    'status=yes,hei ght=200,width=4 50,top=10,left= 10,scrollbars=y es');
    }
    function updatestats (icount,smessag e,iupdate,tcoun t) {
    //var scanStatus = scanWindow.docu ment.form1;
    alert('scanWind owCheck sc=
    ['+scanWindow.do cument.form1.sc anWindowCheck.v alue + ']');
    var objscan = scanWindow.docu ment.form1 ;
    if (iupdate == "doc") {
    objscan.getElem entById("docsta ts").value = icount ;
    }
    if (iupdate == "fld") {
    objscan.getElem entById("fldsta ts").value = icount ;
    }
    objscan.getElem entById("mess") .value=smessage ;
    objscan.getElem entById("total" ).value=tcount;
    }
    </script>
    initStuff is called after the <body> tag, there is then a loop to give
    'scanWindow' time to load and render (this runs from server side to
    prevent any load on the client).
    updatestats, on first call, gives out "scanWindow is undefined" as it
    tries to fire the alert box.
    Previously I had an alert that looked for the field value of a small form
    on the page, that is updated from the popup. This appears to change
    correctly when the popup has rendered its own form (form1 in this
    context).

    what's going wrong?
  • s_m_b

    #2
    Re: object undefined - problem

    "s_m_b" <smb20002ns@hot mail.com> wrote in
    news:Xns969B794 AA1E2Esmb2000ns hotrmailcom@216 .196.97.138:
    [color=blue]
    > here's the code (running from an ASP page):
    > <script language = "JavaScript " type="text/javascript">
    > function initStuff() {
    > var scanWindow = window.open('sc anning.htm', 'scanning',
    > 'status=yes,hei ght=200,width=4 50,top=10,left= 10,scrollbars=y es');
    > }
    > function updatestats (icount,smessag e,iupdate,tcoun t) {
    > //var scanStatus = scanWindow.docu ment.form1;
    > alert('scanWind owCheck sc=
    > ['+scanWindow.do cument.form1.sc anWindowCheck.v alue + ']');
    > var objscan = scanWindow.docu ment.form1 ;
    > if (iupdate == "doc") {
    > objscan.getElem entById("docsta ts").value = icount ;
    > }
    > if (iupdate == "fld") {
    > objscan.getElem entById("fldsta ts").value = icount ;
    > }
    > objscan.getElem entById("mess") .value=smessage ;
    > objscan.getElem entById("total" ).value=tcount;
    > }
    > </script>
    > initStuff is called after the <body> tag, there is then a loop to give
    > 'scanWindow' time to load and render (this runs from server side to
    > prevent any load on the client).
    > updatestats, on first call, gives out "scanWindow is undefined" as it
    > tries to fire the alert box.
    > Previously I had an alert that looked for the field value of a small
    > form on the page, that is updated from the popup. This appears to
    > change correctly when the popup has rendered its own form (form1 in
    > this context).
    >
    > what's going wrong?
    >[/color]

    solved it - misunderstood the previous instructions about using a object
    reference, so had the initStuff function return an object and its fine now!

    Comment

    Working...