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

N

nicver

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.
 
N

nicver

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.
 
A

ASM

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

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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Need Assistance With A Coding Problem 0
Coding question/help 0
Beginner coding 3
Wrong Coding 3
Check forms With JavaScript 1
Friends & coding 2
Small Coding Fear 3
Just started coding and im stuck on a lesson? 1

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top