469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

printing a form

I have a form.
The form has input fields.
The user enters information onto the form presses submit, the information
goes to a database.
All is good.

Now, I want to change the form so that the user can print it.
When printing, the input fields are hidden using css and media='print'.
I'm trying to display the value of the input field so that it is invisible
when media != 'print' as follows
<input class='displayonly' type='text' id='f_agent' name='f_agent'
maxlength='35' />
<span class='pageonly'>
<script language='javascript'>Jot("f_agent");</script>
</span>
where
function Jot(what)
{
document.write(document.getElementById(what).value );
}
and the pageonly/displayonly class have been appropriately defined.

My hope was the entering a value in the input then using print|preview would
result in showing the value just entered would result in the value showing
in the field without the box associate with the input field. But, it
doesn't work.

Any ideas?

Thanks.
Greg

Jul 23 '05 #1
3 1496


Greg Brewer wrote:
I have a form.
The form has input fields.
The user enters information onto the form presses submit, the information
goes to a database.
All is good.

Now, I want to change the form so that the user can print it.
When printing, the input fields are hidden using css and media='print'.
I'm trying to display the value of the input field so that it is invisible
when media != 'print' as follows
<input class='displayonly' type='text' id='f_agent' name='f_agent'
maxlength='35' />
<span class='pageonly'>
<script language='javascript'>Jot("f_agent");</script>
</span>
where
function Jot(what)
{
document.write(document.getElementById(what).value );
}
and the pageonly/displayonly class have been appropriately defined.

My hope was the entering a value in the input then using print|preview would
result in showing the value just entered would result in the value showing
in the field without the box associate with the input field. But, it
doesn't work.


If you don't want input boxes to have borders in the printout consider
to use
@media print {
input, textarea {
border: 0;
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Ok, I tried that and it didn't work but now it does. Thanks :-D

Here's a related problem then.
<input class='displayonly' type='input' id='f_sel0' name='f_sel0'
maxlength='35' />
<span class='pageonly'>
<script language='javascript'>ShowCheck("f_sel0");</script>
</span>

function ShowCheck(what)
{
if (document.getElementById(what).checked) // not 100% about syntax
document.write("<img src='bigredcheck'>");
}

Now, the little check will do but I can't find a way to get rid of the
little box.

Greg

"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...


Greg Brewer wrote:
I have a form.
The form has input fields.
The user enters information onto the form presses submit, the information goes to a database.
All is good.

Now, I want to change the form so that the user can print it.
When printing, the input fields are hidden using css and media='print'.
I'm trying to display the value of the input field so that it is invisible when media != 'print' as follows
<input class='displayonly' type='text' id='f_agent' name='f_agent'
maxlength='35' />
<span class='pageonly'>
<script language='javascript'>Jot("f_agent");</script>
</span>
where
function Jot(what)
{
document.write(document.getElementById(what).value );
}
and the pageonly/displayonly class have been appropriately defined.

My hope was the entering a value in the input then using print|preview would result in showing the value just entered would result in the value showing in the field without the box associate with the input field. But, it
doesn't work.


If you don't want input boxes to have borders in the printout consider
to use
@media print {
input, textarea {
border: 0;
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3
Greg Brewer wrote:
Ok, I tried that and it didn't work but now it does. Thanks :-D

Here's a related problem then.
<input class='displayonly' type='input' id='f_sel0' name='f_sel0'
maxlength='35' />
Are you really using Valid XHTML? If yes, consider to write Valid HTML 4.01
instead. If no, remove the " /", HTML SHORTTAG differs from XHTML SHORTTAG.
See <http://validator.w3.org/>.
<span class='pageonly'>
<script language='javascript'>ShowCheck("f_sel0");</script>
<script type="text/javascript">...</script>
</span>
What about users without support for client-side scripting?
function ShowCheck(what)
{
if (document.getElementById(what).checked) // not 100% about syntax
Make the "input" element a child element of a "form" element. Then you
can use

if (document.forms[...].elements[what].checked)

which is downwards compatible to DOM Level 0 (IE3+, NN3+).
document.write("<img src='bigredcheck'>");
The "img" element misses the required "alt" attribute.

<http://www.w3.org/TR/html4/struct/objects.html#h-13.2>
}

Now, the little check will do but I can't find a way to get rid of the
little box.
What box are you talking about?
[Top post]


Please do not do that, see the FAQ.
PointedEars
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Jody Gelowitz | last post: by
4 posts views Thread by John Baker | last post: by
5 posts views Thread by Randy | last post: by
4 posts views Thread by CsharpNewcommer | last post: by
2 posts views Thread by sitemap | last post: by
2 posts views Thread by =?Utf-8?B?Umlja1NlYW4=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.