Reply
Please verify code
Old 03-29-2005, 02:41 PM Please verify code
Experienced Talker

Posts: 36
Hi:

I'm using the following piece of code to print a form (HTML). Could you tell me whether I have it correct, or is something wrong with it?

echo "<form method=\"POST\" action=\"\">
<table width=\"100%\" border=\"3\" cellspacing=\"4\" cellpadding=\"2\" bordercolor=black align=\"center\">
<tr><th><input type=\"submit\" name=\"PRINT\" value=\"PRINT\" onClick=\"this.style.display=\'none\'; window.print()\"></th></tr>";


The slashes are being used because its part of PHP.

Thanks for your help!

Last edited by common_sense : 03-29-2005 at 02:50 PM.
common_sense is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-29-2005, 02:52 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
I must admit that at the moment I don't know what "window.print()" does but IMHO there shouldn't be extra backslashes before single apostrophes. By the way, onClick should be written rather in small leters, so the code should look like this:

Code:
onclick=\"this.style.display='none'; window.print()\"
Hope, that was the source of your error...
__________________
Seo Link Directory | Kurs C++ | Forum C++
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-29-2005, 02:58 PM
Experienced Talker

Posts: 36
It prints, thank you! It also prints the "PRINT" button. How do I make it only print the form without the print button?
common_sense is offline
Reply With Quote
View Public Profile
 
Old 03-29-2005, 03:08 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Ehmm hmmm. Please give a bit more code, because for sth like that:

Code:
<?php
echo "<form method=\"POST\" action=\"\">
<table width=\"100%\" border=\"3\" cellspacing=\"4\" cellpadding=\"2\" bordercolor=black align=\"center\">
<input type=\"text\" value=\"sample\"/>
<tr><th><input type=\"submit\" name=\"PRINT\" value=\"PRINT\" onClick=\"this.style.display='none'; window.print()\"></th></tr>";
?>
I have only "sample" printed - it was in a border and also a border which comes from the table - but because of that: this.style.display='none'; the "PRINT" wasn't printed because before printing it was hidden, was it?
__________________
Seo Link Directory | Kurs C++ | Forum C++

Last edited by pitbull82 : 03-29-2005 at 03:17 PM.
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-29-2005, 03:12 PM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
To remove the print button from printing only...

Put this in a separate CSS File:
Code:
input#Print {
	display: none;
}
link to it using this: (note media is set to print)
Code:
<link rel="stylesheet" media="print" href="/styles/print.css" />
The button should have it's ID set to Print (or whatever you decide, make sure to change it after tha # in step 1 above as well)

Code:
<input type="submit" id="Print" />
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"
Inoxia Pyrotechnics Supplies | Surrey Angels Cheerleading Squad
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-29-2005, 03:51 PM
Experienced Talker

Posts: 36
I must agree with pitbull82. I used it and it worked! Thanks also to Minaki for his tip. The only problem with Minaki's tip was that the form is created from existing data in the MySql database and thus his suggestion for using the CSS snippet would probably not work.

Thanks guys!
common_sense is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Please verify code
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14216 seconds with 12 queries