jazzyjade
06-03-2003, 11:42 AM
I'm created an exam for an intranet that runs IE 5.0+ and I'm working in a frameset that contains a main frame and a hidden frame. The hidden frame is not visible and is used so that the pages in the main frame can pass variables to it. On the last page in the exam, when the "print" button a function runs that writes a new page and loads it into the main frame. The new page contains all the variables (users scores and selections) that were passed to hidden frame duing the exam.
My problem is that the window of the frameset is a chromeless window without a scroll bar. But the new page is much longer than the window and needs scrolling capabilities. My choices are to:
1) add code to the new page that makes it's own vertical scrollers for scrolling the content of a layer (which contains the variables); or
2) instead of writing a new page with the variables, I could write a new window with the variables and the new window could have a scroll bar
I already tried implementing the 1st option, but it's getting pretty messy. So I'm wondering if the 2nd option might be better. But I'm not sure how to accomplish it. My Dhtml book only states how to write a new page or write a new window but not how to write a new page with variables from a frameset. Is that even possible to do?
Here's a sample of what I'm using currently.
function checkname(){
//before writing new page, this checks to see if the user
//entered data into the form on the current page
name=entername.name.value; //data from form on page
id=enterid.id.value;
if (name==''||id==''){
alert('Please enter your name and your system ID in the boxes at the bottom of the page and then try printing again.');
} else {
//accumulate HTML content for new page
newPage = "<HTML>\n<HEAD>\n<TITLE>Exam for "
newPage += entername.name.value
newPage += "</TITLE>\n"
//automatically prints the page
newPage += "</HEAD>\n<BODY onload='window.print()'>\n"
newPage += "<H1 style='margin-top: 70px;'>"
newPage += entername.name.value
newPage += "'s Exam on Billing Accounts</H1>\n"
newPage += "<P>System ID: "
newPage += enterid.id.value
newPage += "</P>\n"
newPage += "<H3>Case Study One</H3>\n"
newPage += "<B><P>Change the payment method from direct to EFT</B> <BR> Correct: "
newPage += parent.hidden.cs1correct
newPage += "<BR>"
newPage += "Incorrect: "
newPage += parent.hidden.cs1incorrect
newPage += " </P>\n"
newPage += "<P>"
chkResponsesCS1(); //function that writes variables from hidden frame
newPage += "</P>\n"
newPage += "</BODY>\n</HTML>"
//write the page
document.write(newPage)
//close writing stream
document.close()
}
}
//user responses
var userResponsesCS1 = new Array(6)
userResponsesCS1[0] = parent.hidden.cs1_index_response1 //variables from hidden frame
userResponsesCS1[1] = parent.hidden.cs1_index_response2 //example of data that variable represents:
userResponsesCS1[2] = parent.hidden.cs1_index_response3 //Chose provide information to the customer
userResponsesCS1[3] = parent.hidden.cs1_index_response4
userResponsesCS1[4] = parent.hidden.cs1_index_response5
userResponsesCS1[5] = parent.hidden.cs1_index_response6
//writes user responses to newPage function
function chkResponsesCS1(){
for (var i = 0; i<userResponsesCS1.length; i++){
if (userResponsesCS1[i] != undefined){
newPage += userResponsesCS1[i]
newPage += "<br>"
}
}
}
My problem is that the window of the frameset is a chromeless window without a scroll bar. But the new page is much longer than the window and needs scrolling capabilities. My choices are to:
1) add code to the new page that makes it's own vertical scrollers for scrolling the content of a layer (which contains the variables); or
2) instead of writing a new page with the variables, I could write a new window with the variables and the new window could have a scroll bar
I already tried implementing the 1st option, but it's getting pretty messy. So I'm wondering if the 2nd option might be better. But I'm not sure how to accomplish it. My Dhtml book only states how to write a new page or write a new window but not how to write a new page with variables from a frameset. Is that even possible to do?
Here's a sample of what I'm using currently.
function checkname(){
//before writing new page, this checks to see if the user
//entered data into the form on the current page
name=entername.name.value; //data from form on page
id=enterid.id.value;
if (name==''||id==''){
alert('Please enter your name and your system ID in the boxes at the bottom of the page and then try printing again.');
} else {
//accumulate HTML content for new page
newPage = "<HTML>\n<HEAD>\n<TITLE>Exam for "
newPage += entername.name.value
newPage += "</TITLE>\n"
//automatically prints the page
newPage += "</HEAD>\n<BODY onload='window.print()'>\n"
newPage += "<H1 style='margin-top: 70px;'>"
newPage += entername.name.value
newPage += "'s Exam on Billing Accounts</H1>\n"
newPage += "<P>System ID: "
newPage += enterid.id.value
newPage += "</P>\n"
newPage += "<H3>Case Study One</H3>\n"
newPage += "<B><P>Change the payment method from direct to EFT</B> <BR> Correct: "
newPage += parent.hidden.cs1correct
newPage += "<BR>"
newPage += "Incorrect: "
newPage += parent.hidden.cs1incorrect
newPage += " </P>\n"
newPage += "<P>"
chkResponsesCS1(); //function that writes variables from hidden frame
newPage += "</P>\n"
newPage += "</BODY>\n</HTML>"
//write the page
document.write(newPage)
//close writing stream
document.close()
}
}
//user responses
var userResponsesCS1 = new Array(6)
userResponsesCS1[0] = parent.hidden.cs1_index_response1 //variables from hidden frame
userResponsesCS1[1] = parent.hidden.cs1_index_response2 //example of data that variable represents:
userResponsesCS1[2] = parent.hidden.cs1_index_response3 //Chose provide information to the customer
userResponsesCS1[3] = parent.hidden.cs1_index_response4
userResponsesCS1[4] = parent.hidden.cs1_index_response5
userResponsesCS1[5] = parent.hidden.cs1_index_response6
//writes user responses to newPage function
function chkResponsesCS1(){
for (var i = 0; i<userResponsesCS1.length; i++){
if (userResponsesCS1[i] != undefined){
newPage += userResponsesCS1[i]
newPage += "<br>"
}
}
}