views:

10401

answers:

4

I have an html form that a user will fill out and print. Once printed, these forms will be faxed or mailed to a government agency, and need to look close enough like the original form published by said agency that a government bureaucrat doesn't spot that this is a reproduction. The data entered in the form is not saved anywhere or even submitted back to a web server. All that matters is that our users can easily find these forms on our intranet site and type into the form for printing with their normal keyboard.

On the screen I want to leave the radio button as-is, to enforce and communicate radio button usage (choose only one option). However, when it prints out I need it to print with the square checkbox style rather than the round radio button style. I know how to use a media selector to set styles for print only, so that's not the issue. It's just that I don't know if I can style the radio button like I want at all.

If I can't get this working I'm gonna have to create a checkbox to shadow each radio button, use javascript to keep the checkboxes and radio buttons in sync, and css to show the one I care about in the proper medium. Obviously if I can just style them it would save a lot of work.

A: 
VonC
A: 

I don't think you can make a control look like anything other than a control with CSS.

Your best bet it to make a PRINT button goes to a new page with a graphic in place of the selected radio button, then do a window.print() from there.

Diodeus
+11  A: 

In CSS3:

input[type=radio] {content:url(mycheckbox.png)}
input[type=radio]:checked {content:url(mycheckbox-checked.png)}

In reality:

<span class=fakecheckbox><input type=radio><img src="checkbox.png" alt=""></span>

@media screen {.fakecheckbox img {display:none}}
@media print {.fakecheckbox input {display:none;}}

and you'll need Javascript to keep <img> and radios in sync (and ideally insert them there in a first place).

I've used <img>, because browsers are usually configured not to print background-image. It's better to use image than another control, because image is non-interactive and less likely to cause problems.

porneL
A: 

I don't understand this question at all.

You're creating an actual HTML form, but people will never actually use it, only print it out? In that case, do whatever you like. You don't need to use actual form controls. Use images. Use a PDF.

And the forms

need to look as much like the original as possible

but, the original has a radio button and you want the printed form to look different?

Plus, almost too obvious to say, but a radio button only lets you choose one thing and a checkbox lets you choose more than one. So presumably the HTML version has a radio button for a reason?

I think helping you with this question would be a bad thing, at least until you explain some more.

AmbroseChapel
Users will fill out the form and print the completed version, but they will never save the data anywhere. The original has square boxes, but they are used like radio buttons where only one can be selected. So I want a radio button with a square box appearance.
Joel Coehoorn