/    Sign up×
Community /Pin to ProfileBookmark

parent/child oddity

I have a site developed on a server in the US, Unix based…works like a charm. Client asked to develop the same on a server in the Bahamas, NT based…everything is fine EXCEPT for the child/parent window relationship. In trying to debug this whole parent/child thing I noticed the following:

the below routine (all lines) in child simply takes the values from the parent and child, adds them up and if the total exceeds 100 you get the alert message…this works on the domestic site just fine, not the offshore site…however, if I strip out code line 4, (result=+=opener…)then run, the alert comes up! So it seems that the reference to opener.document.forms[0] when you’re in the child window doesn’t work….in the parent window (i.e., main form), a variant of the same routine is present BUT code line 5 (result=+=document.childForm1…) doesn’t exist…routine works fine under both domains so I’m guessing when you’re in the parent window the reference opener.document.forms[0] is legit… I thought maybe trying to name the parent window, then reference the name in child…NO GO. Is this all happening because of NT vs Unix server??? Thoughts please. DESPERATE!

“<script language=”JavaScript”>
function sum(objRef) {
var result = 0;
result += opener.document.forms[0].CndnFBpc.value – 0;
result += document.childForm1.cf1f.value – 0;
if (result > 100)
alert(“Your total percent allocation exceeds 100%…please check your percent distributions”);
}</script>”

Thanks,
Ron

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@oleragSep 20.2004 — Several comments/things to check:

1. Server-side? I assume you meant "client" workstations. You

didn't mention the NT client (assuming IE6??).

2. The JS tag should be:

<script language="text/javascript"> (with no preceding "double-quote").

3. Can't the "result" assignment simply be:

result = parseInt(document.childForm1.cf1f.value) +

parseInt(opener.document.forms[0].CndnFBpc.value);

4. Finally, what is your browser's JS Console reporting as an

error?
Copy linkTweet thisAlerts:
@rjusaauthorSep 20.2004 — olerag,

Thanks for the reply.

Let me address Comment #2 first...(I have the parent reference line 'result += opener.document.forms[0].CndnFBpc.value - 0;' commented out for testing purposes...)if I put in a %>100 I receive the error message as expected...if I change the JS tag to your suggestion <script language="text/javascript"> and then run after reloading saved code, %>100 DOES NOT return error message...changed back to <script language="JavaScript">, run after reloading saved code, error message returned. Hmmm?

Comment #3...kinda don't know if your suggested code line works or not...I did try it and entering a %>100 DID NOT return error message BUT I didn't expect it to because I believe somehow the (parent) reference to opener.document.forms[0]shuts down the routine...if I can ever figure out how to properly reference the parent I'll try again, your version seems much simpler.

Comment4...browser Netscape, Version 7.2...when I answer the 6 questions in the child and press update, child clears and nothing is updated in the parent...JavaScript console gives me 6 of the following...Error: uncaught exception: Permission denied to get property HTMLDocument.forms...ran same on Unix version and everything OK...

Comment1...by server I mean the machine the code resides on...unclear?

Thanks again,

Ron
Copy linkTweet thisAlerts:
@oleragSep 20.2004 — Geez - still sleepy, I guess. How about...

<script type="text/javascript">

Anyway, you've probably discovered the problem. NN7.2 isn't letting

you reference the "parent" the way it is currently written, hence

the "uncaught exception".
Copy linkTweet thisAlerts:
@rjusaauthorSep 20.2004 — olerag,

changed JS tag to <script type="text/javascript">...with parent reference still commented out, %>100 error DOES appear...with parent reference commented "in", still no go...although our tags have the same result, will go with yours since I noticed much of the rest of my code follows this convention...

with regard to the parent reference... I would think that the domestic site on Unix server under NN7.2 would give me the same result...but it doesn't, works flawlessly!... also, when I run this under IE I get the same results...Unix parent reference works, NT doesn't...

Stumped!!!

Thanks again
×

Success!

Help @rjusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...