473,385 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Jul 25 '05 #1
4 3078


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/
Jul 25 '05 #2
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.

Jul 25 '05 #3
I apologize, the onload method actually works. Thanks!

Jul 25 '05 #4
ASM
ni****@yahoo.com wrote:
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;

--
Stephane Moriaux et son [moins] vieux Mac
Jul 25 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matt | last post by:
When I do the following, the mycode will still execute. The reason I put window.opener=top; is to disable the close confirmation dialog box. window.opener = top; window.close(); //mycode... ...
19
by: Mason A. Clark | last post by:
How was I to know that "top" means "top" in MSIE6 ?? I was testing <a name="top"></a> at the top of the page with <a href="#top>go to top</a> at the bottom of the page. It always worked in...
6
by: Mason A. Clark | last post by:
LAST WORD(s): 1. MSIE6 and Firefox will go to the top of the page on command <a href="#top">go upsy</a> even if there is NO name="top" or id="top" They know what a "top" is :-) Opera...
1
by: Achim Domma (SyynX Solutions GmbH) | last post by:
Hi, is there a possibility to set the font size to a percent value of the "top level" font size? For example: The font size of the body might be 100% and I have a div which should have a...
3
by: Brett Romero | last post by:
I have an MDI Parent form with a toolstrip and menustrip. The menustrip is always the top most. Both are Docked to Top. I contemplated using a toolstripcontainer but then removed it. I had to...
6
by: Ray Schumacher | last post by:
What is the feeling on using "parent" in a class definition that class methods can refer to, vs. some other organization ? Should all relevant objects/vars just be passed into the method as needed?...
1
by: sheldonlg | last post by:
I define a div, excItem, with absolute positioning and with a top of 400px. I then call a javascript function which does toggling of visibility and should do positioning as well. I loop though...
1
by: power9888 | last post by:
Can anyone help to resolve this issue please? I have a bookmark in the page #top. I need to use javascript to move to the move mark top. However, the javascript location.href = "#top"; does not...
3
by: eBob.com | last post by:
How does a "sub-form", i.e. one invoked by another form, determine anything about the form which brought it into existence, i.e., I suppose, instantiated it? I wanted to so something like this ......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.