1

I'm working with Dreamweaver, coded in php.

On one of my pages, I'm trying to add 2 different print buttons, each one printing a differrent portion of the webpage. For example, one print button is printing the first paragraph and the other print button is printing the second paragraph.

I did the print CSS for both buttons and I linked each to its respective print CSS, but the second print CSS overrules the first one, and so I end up having two print buttons with the same CSS...

What do I need to do?

Fabián
  • 565
  • 1
  • 7
  • 30
VLP
  • 21
  • 4

1 Answers1

4

You could dynamically change the print CSS based upon which button is clicked with something like this:

Add an id to your stylesheet reference:

<link rel="stylesheet" href="print1.css" id="printCss" media="print">

Add an on click event to your button:

<input type="button" onclick="swapCss();"/>

Dynamically swap the css file:

function swapCss() {
    document.getElementById('printCss').href = 'print2.css';
}
zigdawgydawg
  • 2,046
  • 13
  • 10
  • Would it be the same if i use, instead of buttons, links? – VLP Aug 28 '13 at 21:08
  • Yes, except you would want the link to look something like this (so that it doesn't take the user to a new page): `print`. – zigdawgydawg Aug 28 '13 at 21:09
  • Now, would it be completely wrong if i ask you something else, completely different... Since we're talking already maybe you can help me again... – VLP Aug 28 '13 at 21:34
  • Do you know anything about php includes? Im trying to add some png images but with the 'swap' function, (an image that when the cursor is on top changes). But everytime i put on the include it shows an error message... I have the images in a different file and i bring it to the web page i want to show it in as php include("_includes/swaplinks.php") which is the path but the error says it doesnt work – VLP Aug 28 '13 at 21:35
  • @VLP I certainly don't mind helping you out, but proper ettiquete on Stack Overflow dictates that you should ask a new question if it is unrelated to the current one. You might want to check this [link](http://stackoverflow.com/about). I will certainly keep an eye out for your new question. Also, if an answer fixes your issue, it is a good idea to accept it. That way everyone knows it is resolved. – zigdawgydawg Aug 28 '13 at 21:42