Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

populate a pop up div from the opener

Posted on 2012-08-22
2
Medium Priority
?
650 Views
Last Modified: 2012-08-23
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>
0
Comment
Question by:KeithMcElroy
2 Comments
 
LVL 9

Expert Comment

by:djon2003
ID: 38323470
after your comment for h insertion :
popup.document.getElementById('printarea').innerHTML = h;

Open in new window

0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 38324088
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question