/    Sign up×
Community /Pin to ProfileBookmark

Calling parent window’s function with values

I have 2 HTML files that I’d like to have interact. One file has a button that opens a new window with the 2nd file which is actually an ASP page. When I submit the ASP page, I want to have the child window call a function in the parent using the values that were used in the ASP post. However, my code doesn’t appear to be working. I’m getting into the function in my child window to call the parent’s function, but the code in the parent isn’t running. Can someone help me?
Here is the code I have.

First, in the parent, in the javascript portion:

[code=html]function updateJackTbl(unit, name, jack, term, back){
alert(“In updateJackTbl”);
tbl = document.getElementById(“unitTbl”);
if (unit==”A”) {
numRows = tbl.getElementsByTagName(“TR”).length-2;
row = tbl.rows(numRows);
} else {
numRows = tbl.getElementsByTagName(“TR”).length-1;
row = tbl.rows(numRows);
}
tblRef.deleteRow(row);
newRow = tblRef.insertRow(numRows);
newCell = newRow.insertCell(0);
newTxt = document.createTextNode(unit);
newCell.appendChild(newTxt);
}[/code]

Then, in the child window, I have the following. First in the script section, I have:

[CODE]function updateOpenerTbl() {
alert(“call updateJackTbl “+window.opener)
var unit = “A”;
var uName = “Test”
var rID = 500;
var cblID = 1058;
var term = “P3”;
var bckshl = “N/A”;
var jNum = “J4”;
window.opener.updateJackTbl(unit, uName, jNum, term, bckshl);
window.close();
}[/CODE]

And the <body> tag has:

[CODE]<body onload=”javascript:updateOpenerTbl()”>[/CODE]

Again, I’m getting the alert that says “call updateJackTbl [object]”, but I’m not getting “In updateJackTbl”.

I hope someone can help. It would be very much appreciated.

Chris

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@philmee95Aug 14.2009 — Are you sure the function runs in the page when not called by the opener?


where does tbleRef come into scope in your function?

tblRef.deleteRow(row);

tbl = document.getElementById("unitTbl");
Copy linkTweet thisAlerts:
@chrscoteauthorAug 17.2009 — Oops, that would be the problem right there. I must have just skipped right over that line and not noticed the difference in the variable names. I changed the tblRef to tbl and it works fine now.

Thank you for the help. As a programmer, I have seen it many times where a 2nd person looking at the code will find the errors that the one coding would miss.

Chris
×

Success!

Help @chrscote 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.18,
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,
)...