0

I am trying to check on a checkbox to select one, many or all and send them to be printed when the user clicks on the "print me" button. I am lost on this one, has anyone done anything similar that I can see how it can be done right? Here is my test code for my issue.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Select and Print</title>

<script src="/jquery-1.11.min.js"></script>
<script>

$(document).ready(function() {
$('#selecctall').click(function(event) { 
    if(this.checked) {

        $('.checkbox1').each(function() { 
            this.checked = true;  // select all checkboxes with class "checkbox1"

            printDoc(docUrl);

        });
    }else{

        $('.checkbox1').each(function() { 
            this.checked = false; // deselect all checkboxes with class "checkbox1"                      
        });        
    }
 });

});

function printDoc(gotUrl) {

var doc = window.open(gotUrl);
doc.print();
doc.close();

}

</script>

</head>

<body><form action="doit.pl" method="post">
 </br>
<input type="checkbox" id="selecctall"/> Select All
<input class="checkbox1" type="checkbox" name="check[]" value="names.html"></br>
<input class="checkbox1" type="checkbox" name="check[]" value="copy.html"></br>
<input class="checkbox1" type="checkbox" name="check[]" value="card.html"></br>
<input class="checkbox1" type="checkbox" name="check[]" value="page.html"></br>
<input class="checkbox1" type="checkbox" name="check[]" value="test.html"></br>
<input type="submit" name="print me"></br>
</body></form>

</html>

Thanks for the Help!

Andre
  • 819
  • 3
  • 15
  • 30
  • @EoiFirst it seems like he wants one, many, or all. A radio cannot do this. – dmgig Jun 02 '14 at 15:56
  • This is a tough one. I'm not sure that it is possible to ask multiple pages to print at once. What kind of files are these going to be? – dmgig Jun 02 '14 at 15:58
  • seems like the missing magic is doc.focus(); before the print method is called. there are a couple answer's here on SO about printing from a child window like this one: http://stackoverflow.com/questions/9852190/js-window-open-then-print – jme11 Jun 02 '14 at 16:08
  • It is tough, they will be all .html files and I can't find anything like it to start with. Even if I replace the checkbox(s) with an onclick event would also help. – Andre Jun 02 '14 at 17:13
  • I am trying to make things simple, I am testing using this code, but it prints a blank page, any thoughts? – Andre Jun 02 '14 at 17:28

0 Answers0