Print URLs Selected In CheckBox

[Total: 0    Average: 0/5]

This shows how to print a list of URLs given they are selected in the form checkbox.

Body Code:

<script>
// This defines the other urls to print.
// NOTE: These other urls must be specified by
//       relative path! (they can not be from another
//       domain!)
var _locs= new Array();
    _locs[0] = "b.html";
	_locs[1] = "c.html";
document.write('<form name=exf1>');
for (var i in _locs) {
  document.write('<input type=checkbox value='+i+' name=c1 >'+_locs[i]+'<BR>');
}
document.write('<input type=button value="Print Selected Items" onclick="doIt()">');
document.write('</form>');

var newWin=null;
function doIt() {
  for (var i=0;i < document.exf1.c1.length; i++) {
    if (document.exf1.c1[i].checked) {
	  alert("Going to print: "+_locs[i]);
	  newWin = window.open(_locs[i]);
	  newWin.print();
	  newWin.close();
	}
  }
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *