populate a pop up div from the opener

I have not been able to get the h variable to be populated into the div tag on the pop up

/*
print-functions.js

WORK LOG
Date    Name      Item(s)      Comments
8/22/2012  keith    code review    WARN:  needs refinement,

*/
function closePrint()
{
      
      $('#print-region').hide()
      $('#print-region').html("")
      
}

function printVersion()
{
      h = $('#sectionA').html()
      h += $('#sectionB').html()
      h += $('#sectionC').html()
      h += $('#sectionD').html()
      h += $('#sectionE').html()
      h += $('#sectionF').html()
      h += $('#sectionG').html()
      h += $('#sectionH').html()
      h += $('#sectionI').html()
      h += $('#sectionJ').html()

      var popup = window.open( "HRPANFRM/popup/print.html", "", "status = 1, width=400,height=200,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes" )


//populate h into  the printarea div in the popup
      
}


//:popup file  print.html
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"         type="text/javascript"></script>
<script src="../jq/print-element.js" type="text/javascript"></script>                              <!--jquery library-->
<SCRIPT LANGUAGE=javascript>
<!--
function printthis()
{
$('#printarea').printElement()
}

      
      
      
//-->
</SCRIPT>

</head>
<body>
<div id="printarea">

print area  
</div>
<a href='javascript:printthis()'>Print</a>
</body>
</html>
KeithMcElroyAsked:
Who is Participating?
 
ZvonkoSystems architectCommented:
Hello KeithMcElroy,

extend your popup file print.html to this:
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"         type="text/javascript"></script> 
<script src="../jq/print-element.js" type="text/javascript"></script>                              <!--jquery library-->
<SCRIPT LANGUAGE=javascript>
<!--
function printthis()
{
$('#printarea').printElement()
}        
//-->
</SCRIPT>
</head>
<body>
<div id="printarea">
print area  
</div>
<script>opener.printPopupVersion()</script>
<a href='javascript:printthis()'>Print</a>
</body>
</html> 

Open in new window

Your main window needs the called function that is here:
function printPopupVersion(){
      h = $('#sectionA').html()
      h += $('#sectionB').html()
      h += $('#sectionC').html()
      h += $('#sectionD').html()
      h += $('#sectionE').html()
      h += $('#sectionF').html()
      h += $('#sectionG').html()
      h += $('#sectionH').html()
      h += $('#sectionI').html()
      h += $('#sectionJ').html()
	  var popup = window.open( "", "printWin");
	  popup.document.getElementById("printarea").innerHTML=h;
}

Open in new window

But to have acces to the popup window does the popup window need a name at open time.
Therefore your function printVersion() looks then like this:
function printVersion(){
      var popup = window.open( "HRPANFRM/popup/print.html", "printWin", "status = 1, width=400,height=200,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes" )
}

Open in new window


Give it a try.
0
 
djon2003Commented:
after your comment for h insertion :
popup.document.getElementById('printarea').innerHTML = h;

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.