<html> <head> <style type="text/css" media="print"> textarea {border:0;} </style> <script> function countLines(obj){ //count number of lines entered return obj.value.match(new RegExp("(\\n)","g")).length; } function doPrint(){ txta = document.getElementById("ta"); //expand textarea according to entered text txta.rows=countLines(txta); window.print(); } </script> </head> <body> <input type="button" text="Print" onclick="doPrint()"> <form> <textarea id="ta" cols="80" rows="2">Some text with line breaks some more texts</textarea> </form> </body> </html>
Friday, May 26, 2006
Printable Forms with Javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment