J
jr
All I want to do is to fire a javascript when the user clicks the
'print the current page' button.
It doesn't fire. I don't know if I need another event besides
onClick? This is what I have in the form but it doesn't work.
I would really like it if the xmlhttp response text came back in the
printer response div.
<div id="printbutton">
<input type="button" name="print" value="Print this page"
id="printbutton" "printFromHere()";>
</div>
<div id='printer_response'>
</div>
function printFromHere(){
var xhr = document.forms[0].search_zonenm.value;
if ( window.XMLHttpRequest ) {// code for IE7+,
Firefox, Chrome, Opera, Safari
xhr=new XMLHttpRequest();
}else{ // code for IE6, IE5
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)
document.getElementById.printer_response="Received:" +
xhr.responseText;
else
document.getElementById.printer_response ="Error code
" + xhr.status;
}
};
xhr.open(GET, "print_test.php", true);
xhr.send(null);
}
thanks,
'print the current page' button.
It doesn't fire. I don't know if I need another event besides
onClick? This is what I have in the form but it doesn't work.
I would really like it if the xmlhttp response text came back in the
printer response div.
<div id="printbutton">
<input type="button" name="print" value="Print this page"
id="printbutton" "printFromHere()";>
</div>
<div id='printer_response'>
</div>
function printFromHere(){
var xhr = document.forms[0].search_zonenm.value;
if ( window.XMLHttpRequest ) {// code for IE7+,
Firefox, Chrome, Opera, Safari
xhr=new XMLHttpRequest();
}else{ // code for IE6, IE5
xhr=new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)
document.getElementById.printer_response="Received:" +
xhr.responseText;
else
document.getElementById.printer_response ="Error code
" + xhr.status;
}
};
xhr.open(GET, "print_test.php", true);
xhr.send(null);
}
thanks,