Problem with ASP/Javascript coding with frames and "top.parent"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nicver@yahoo.com

    Problem with ASP/Javascript coding with frames and "top.parent"

    I am fixing a client's Web site and I do not have the time to reprogram
    things my way, and the last hurdle I have is with a piece of javascript
    embedded in an ASP snippet.

    The payment form is named "frmPayment ". The page itself is in a frame
    named "main".

    The form contains 1 or many items. The amount of each item can be
    modified from a drop down (this is for a classified ads system, you can
    select a different ad type per ad) and the grand total is changed.

    Next to each drop down, is a textbox named textbox0, textbox1, etc...

    When a different value is selected in a drop-down, a piece of ASP is
    fired in another, invisible frame, named "process".

    top.parent.proc ess.location.hr ef = 'process_setadc ost.asp?IDX=' + idx +
    '&AdTypeID=' + val;

    This ASP first retrieves the ad cost into adCost by using the value
    passed in AdTypeID. (So far, it works. Pretty exotic technique).

    The following code is supposed to update txtAdCost[idx], redo the total
    and change the value in the total field, which is then used in the
    following page (credit card auth).
    -----------------
    <%
    Dim pintIDX
    pintIDX = Request("IDX")
    %>
    <HTML>
    <HEAD>
    <script language="javas cript">
    var adCost = '<%=AD.GetAdCos t()%>';
    var total = 0;
    var f = top.parent.main .document.frmPa yment;

    f.txtAdCost<%=p intIDX%>.value = adCost;

    var uBound = f.UBOUND.value;
    var loopAdCost = 0;
    for (i = 0; i <= uBound-1; i++) {
    loopAdCost = f['txtAdCost' + i].value;

    if (loopAdCost == '') {
    loopAdCost = 0;
    }
    total = total + eval(loopAdCost );
    }
    f.AMT.value = total;
    </script>
    </HEAD>
    <BODY>

    -----------------

    var adCost = '<%=AD.GetAdCos t()%>'; works fine. The ASP uses the
    GetAdCost subclass and no problem there.

    I keep getting the error message: 'f.txtAdCost0' is null or is not an
    object.

    When I replace the "f" with "top.parent.mai n.document.frmP ayment", it
    tells me that 'top.parent.mai n.document.frmP ayment.txtAdCos t0' is null
    or is not an object.

    Obviously, it is not using the right handler to instantiate the form
    into "f".

    I have tried all types of solutions. I cannot reprogram it all, the
    client does not have the time nor the money, and I don't have the time
    redesign this Web site from the ground up.

    Thanks for your help, guys, I have tried everything for hours and gave
    myself a major headache on this one!

    Note that all the other ASP codes loaded in the "process" frame work
    fine.

  • Danny

    #2
    Re: Problem with ASP/Javascript coding with frames and &quot;top.paren t&quot;



    Runtime got you, elementary my dear Watson. First off, do you really
    have to get the value from the server for the price? if it's only a
    calculation, how about sending all values at once and have js do it on the
    client with no extra server requests? The parser parses the js, but
    you're probably at the <head> element, means, that the parser hasn't
    parsed <body> or any of its children, so, there's no
    document.ANYELE MENT.ANYCHILDRE N, simple solution is, move the <script>
    element to the very bottom </html> or </body>, or make it a function and
    have it run onload="" of <body>

    Danny

    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

    Comment

    • nicver@yahoo.com

      #3
      Re: Problem with ASP/Javascript coding with frames and &quot;top.paren t&quot;

      Sorry, it is still not doing the trick. I tried moving or naming the
      function and calling it with onload as well...

      By the way, the text box is properly named txtAdCost0, etc... in both
      cases (I realized I mistyped it).

      If I cannot fix it, I will reprogram it and use a <Option value="">
      which will encapsulate the ad id, the ad type and the price properly
      separated.

      I agree, it is gauche to requery the server each time somebody selects
      something in a drop down.

      Comment

      • nicver@yahoo.com

        #4
        Re: Problem with ASP/Javascript coding with frames and &quot;top.paren t&quot;

        I apologize, the onload method actually works. Thanks!

        Comment

        • ASM

          #5
          Re: Problem with ASP/Javascript coding with frames and &quot;top.paren t&quot;

          nicver@yahoo.co m wrote:[color=blue]
          > I keep getting the error message: 'f.txtAdCost0' is null or is not an
          > object.[/color]

          what does your asp with : pintIDX ?
          in :
          f.txtAdCost<%=p intIDX%>.value = adCost;

          try somenthing else this way :
          f.txtAdCost.val ue = adCost<%=pintID X%>;

          the trouble seems to come with this '0' added to txtAdCost
          error message: 'f.txtAdCost0'
          as JS wait something like :
          f.txtAdCost.val ue

          is there several 'txtAdCost' in your form ?
          if yes, correction ->
          f.txtAdCost[<%=pintIDX%>].value = adCost;
          if not try :
          f.txtAdCost.val ue = adCost;

          --
          Stephane Moriaux et son [moins] vieux Mac

          Comment

          Working...