dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Print only text that has been selected with a checkbox

  1. #1
    Join Date
    Dec 2015
    Posts
    2

    Print only text that has been selected with a checkbox

    Hello, I hope someone can help me out a little. I don't even know where to start with this. I operate a few simple webpages for local non-profit organizations. I am a media designer and now my way around CSS but I have no javascript/jquery/php coding skills. Two of the non-profit organizations now have approached me and asked to implement a feature that has totally caught me off guard. They both have a rather long FAQ section. Now they want me to add a type of checkbox after each question and a print button at the bottom and only the questions where the checkboxes have been checked should be printed.

    My idea was to create a div for every question which includes a checkbox. The print button at the bottom then should check whether a box is checked or not and only send the checked divs to the printer. In theory, this sounds quite easy - but since I have no coding skills, I don't know how to create a print function.

    Someone then suggested to use a drag& drop jquery function and have people just drop the questions they want printed to a predefined area and just print that area. In theory, it sounds nice - again, I have no coding skills.

    Can someone point me into the direction of a tutorial or jquery plugin that could accomplish this? Is jquery even the right way to do this? I tried google for the last few days but came up pretty much empty handed - I guess I must be using the wrong search terms since I can't believe that no one has ever done such a thing.

  2. #2
    Join Date
    Oct 2013
    Posts
    1,458
    Who needs JavaScript?

    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>your title</title>
    
    <style>
    @media print {
    	input[type=checkbox], .faq { display: none; }
    	input[type=checkbox]:checked ~ div { display: block; }
    }
    </style>
    
    </head>
    
    <body>
    <div>
    	<input type="checkbox">
    	<div class="faq">
    		<p>Question 1</p>
    		<p>Answer 1</p>
    	</div>
    </div>
    
    <div>
    	<input type="checkbox">
    	<div class="faq">
    		<p>Question 2</p>
    		<p>Answer 2</p>
    	</div>
    </div>
    
    </body>
    </html>
    And if you really really need a print button add this to the code:
    HTML Code:
    <button onclick="window.print()">Print</button>
    In dog beers I've only had one.

  3. #3
    Join Date
    Dec 2015
    Posts
    2
    Wow, this is awesome, thank you so much! It does exactly what I want it to do! Kudos!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles