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.