printing a form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Greg Brewer

    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='displayo nly' type='text' id='f_agent' name='f_agent'
    maxlength='35' />
    <span class='pageonly '>
    <script language='javas cript'>Jot("f_a gent");</script>
    </span>
    where
    function Jot(what)
    {
    document.write( document.getEle mentById(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



  • Martin Honnen

    #2
    Re: printing a form



    Greg Brewer wrote:
    [color=blue]
    > 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='displayo nly' type='text' id='f_agent' name='f_agent'
    > maxlength='35' />
    > <span class='pageonly '>
    > <script language='javas cript'>Jot("f_a gent");</script>
    > </span>
    > where
    > function Jot(what)
    > {
    > document.write( document.getEle mentById(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.[/color]

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

    --

    Martin Honnen


    Comment

    • Greg Brewer

      #3
      Re: printing a form

      Ok, I tried that and it didn't work but now it does. Thanks :-D

      Here's a related problem then.
      <input class='displayo nly' type='input' id='f_sel0' name='f_sel0'
      maxlength='35' />
      <span class='pageonly '>
      <script language='javas cript'>ShowChec k("f_sel0");</script>
      </span>

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

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

      Greg

      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:40926145$1 @olaf.komtel.ne t...[color=blue]
      >
      >
      > Greg Brewer wrote:
      >[color=green]
      > > I have a form.
      > > The form has input fields.
      > > The user enters information onto the form presses submit, the[/color][/color]
      information[color=blue][color=green]
      > > 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[/color][/color]
      invisible[color=blue][color=green]
      > > when media != 'print' as follows
      > > <input class='displayo nly' type='text' id='f_agent' name='f_agent'
      > > maxlength='35' />
      > > <span class='pageonly '>
      > > <script language='javas cript'>Jot("f_a gent");</script>
      > > </span>
      > > where
      > > function Jot(what)
      > > {
      > > document.write( document.getEle mentById(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[/color][/color]
      would[color=blue][color=green]
      > > result in showing the value just entered would result in the value[/color][/color]
      showing[color=blue][color=green]
      > > in the field without the box associate with the input field. But, it
      > > doesn't work.[/color]
      >
      > 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/
      >[/color]


      Comment

      • Thomas 'PointedEars' Lahn

        #4
        Re: printing a form

        Greg Brewer wrote:
        [color=blue]
        > Ok, I tried that and it didn't work but now it does. Thanks :-D
        >
        > Here's a related problem then.
        > <input class='displayo nly' type='input' id='f_sel0' name='f_sel0'
        > maxlength='35' />[/color]

        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.or g/>.
        [color=blue]
        > <span class='pageonly '>
        > <script language='javas cript'>ShowChec k("f_sel0");</script>[/color]

        <script type="text/javascript">... </script>
        [color=blue]
        > </span>[/color]

        What about users without support for client-side scripting?
        [color=blue]
        > function ShowCheck(what)
        > {
        > if (document.getEl ementById(what) .checked) // not 100% about syntax[/color]

        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+).
        [color=blue]
        > document.write( "<img src='bigredchec k'>");[/color]

        The "img" element misses the required "alt" attribute.

        <http://www.w3.org/TR/html4/struct/objects.html#h-13.2>
        [color=blue]
        > }
        >
        > Now, the little check will do but I can't find a way to get rid of the
        > little box.[/color]

        What box are you talking about?
        [color=blue]
        > [Top post][/color]

        Please do not do that, see the FAQ.


        PointedEars

        Comment

        Working...