Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 36
Trades: 0
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 03:50 PM..
common_sense is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-29-2005, 03:52 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Trades: 0
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...
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
pitbull82 is offline
Reply With Quote
View Public Profile Visit pitbull82's homepage!
 
Old 03-29-2005, 03:58 PM
Experienced Talker

Posts: 36
Trades: 0
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, 04:08 PM
pitbull82's Avatar
Super Talker

Posts: 147
Name: Marcin Nabiałek
Location: Poland, Częstochowa
Trades: 0
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?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

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

Posts: 1,626
Location: Guildford, UK
Trades: 0
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!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-29-2005, 04:51 PM
Experienced Talker

Posts: 36
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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 1.58113 seconds with 12 queries