Results 1 to 5 of 5
  1. #1

    Default CSS Help - <div> tags trouble


    Hey guys, I have a working experience with CSS but only on design and not on how div tags are structured and interpreted. I use Dreamweaver mostly on design because I am aiming at speed.

    Here's the problem. I'm trying to pull off a printing (yes, using a printer to print stuff) trick for fun with java's window.print(); and i'm running out of ideas on how to solve this. Here's a sample code I wrote for everyone:

    Code:
    <html>
    <head>
    <style type="text/css">
    	.printablediv {
    		display: none;
    	}
    	@media print {	
    		body * {
    			display: none;
    		}
    		.printablediv {
    			display: block;
    		}
    	}
    </style>
    </head>
    <body>
    	<div class="printablediv">Line 1</div>
    	<div>Line 2.</div>
    	<input type="button" onclick="window.print();" value="Print"/>
    </body>
    </html>
    When you open this code in a browser, you will see that the text 'Line 2' and the button appears. When you click the print button, it shows a printing dialog window. If you try to print the page, or try to print preview it, you will see that the text 'Line 1' only appears. This is correct but there's a problem. If you try to apply this method in existing systems or in real applications, the div with the class printable div will more likely wrapped in another <div>. If you wrap that div and print it, the text Line 1 wont appear.

    What I'm trying to achieve here is that I want to print only a div of my choice. If you're going to use this in real life applications, you're more likely working on an e-cart but this is not the case with me. You can use this method to print receipts. The only trouble you're going to have to think is the formatting to the page

    Solutions, anyone?

  2. #2
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018
    gamiti og id pre...para ma isolate nimo

    unya ijavascript na lang og tarong...

  3. #3
    I'm also thinking about using id instead of class. But I won't be able to test it until I come home tonight.

  4. #4
    [edited]

    it does not work, i'm testing the wrong code.
    Last edited by aozora; 07-09-2010 at 08:56 PM.

  5. #5

  6.    Advertisement

Similar Threads

 
  1. ~Help My Pet Is In Trouble! Need Advice~
    By bad donkey! in forum Pet Discussions
    Replies: 232
    Last Post: 11-17-2012, 08:37 AM
  2. Help! My samsung gt-I5500 wont start up!
    By redcheek in forum Computer Hardware
    Replies: 8
    Last Post: 02-29-2012, 08:46 PM
  3. Help Coin slot for PC trouble!
    By jatz in forum Computer Hardware
    Replies: 4
    Last Post: 04-06-2011, 07:47 PM
  4. Replies: 16
    Last Post: 12-12-2005, 10:37 PM
  5. Need help with CSS png transparency.
    By silent-kill in forum Websites & Multimedia
    Replies: 1
    Last Post: 07-01-2005, 11:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top