Connecting Tech Pros Worldwide Forums | Help | Site Map

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

nicver@yahoo.com
Guest
 
Posts: n/a
#1: Jul 25 '05
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.process.location.href = 'process_setadcost.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="javascript">
var adCost = '<%=AD.GetAdCost()%>';
var total = 0;
var f = top.parent.main.document.frmPayment;

f.txtAdCost<%=pintIDX%>.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.GetAdCost()%>'; 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.main.document.frmPayment", it
tells me that 'top.parent.main.document.frmPayment.txtAdCost0' 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
Guest
 
Posts: n/a
#2: Jul 25 '05

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




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.ANYELEMENT.ANYCHILDREN, 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/
nicver@yahoo.com
Guest
 
Posts: n/a
#3: Jul 25 '05

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


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.

nicver@yahoo.com
Guest
 
Posts: n/a
#4: Jul 25 '05

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


I apologize, the onload method actually works. Thanks!

ASM
Guest
 
Posts: n/a
#5: Jul 25 '05

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


nicver@yahoo.com 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<%=pintIDX%>.value = adCost;

try somenthing else this way :
f.txtAdCost.value = adCost<%=pintIDX%>;

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

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

--
Stephane Moriaux et son [moins] vieux Mac
Closed Thread