This is my first JavaScript attempt, so I apologize if things are a little mangled.
I have two html pages (Certificate1.html and Certificate2.html). What I'm trying to do is prompt the user for his/her name on Certificate1.html, then pass that information to Certificate2.html. At this point the user's name will be displayed in a certificate that (s)he can print.
Both html pages reference the same JavaScript file (Certificate1.js). The first page calls passName():
function passName() {
FirstN = document.frmUserName.inFirstN.value;
LastN = document.frmUserName.inLastN.value;
// alert(FirstN); // good
// alert(LastN); // good
var Cert = window.open("Certificate2.html");
Cert.FirstN = FirstN;
Cert.LastN = LastN;
//alert(Cert.FirstN); //good
//alert(Cert.LastN); //good
}
This seems to be working correctly. Where I'm stuck is the function placeName() that Certificate2.html calls. I have it firing onLoad, and I know it's accessing the function correctly (I just stuck an alert in there and it came up). I don't know how to access the FirstN and LastN variables that I passed to Cert in passName(). I've tried document.FirstN but I get "undefined." How can I access the FirstN and LastN variables that I (think I) passed?
Thanks! -Kristin
UPDATE:
Got it!!!
I didn't need to access it via window.opener - I had passed in the variables to the window, so I was able to access them directly.
function placeName() {
//alert(FirstN);
document.getElementById("pUserName").innerHTML = FirstN + " " + LastN;
}
Thanks guys!! -Kristin