window.form.submit

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sten Larsson

    #1

    window.form.submit

    Hi All !

    I have to code below - works great in IE and Opera, but does not work
    at all in Firefox / Netscape. Any ideas?

    The problem is that nothing happens when clicking printer friendly.

    Thanks!
    -sten

    ....
    function onPrint()
    {
    window.printFor m.submit();
    }
    ....
    <td>
    <a href="#" onClick="onPrin t(); return false;">printer friendly</a>
    </td>
    ...
    <form name="printForm " ction="/xasp?print=on" method=post>
    ...
    <input type="hidden" name="TestField " value="dummy">
    <input type="hidden" name="Date" value="">
    ...
    </form>
    ...
  • Michael Winter

    #2
    Re: window.form.sub mit

    On 26 Oct 2004 09:16:27 -0700, Sten Larsson <sten_larsson@y ahoo.com> wrote:
    [color=blue]
    > I have to code below - works great in IE and Opera, but does not work
    > at all in Firefox / Netscape. Any ideas?[/color]

    You can't access an element using its name or id as a global variable.
    Opera only allows it to be compatible with IE. Reference the form properly:

    document.forms['formName']
    [color=blue]
    > The problem is that nothing happens when clicking printer friendly.[/color]

    Nothing will happen with Javascript disabled, either. If you want to make
    something "printer friendly", write a print stylesheet that hides the
    superfluous parts of the page. Don't maintain multiple versions of a page.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Martin Honnen

      #3
      Re: window.form.sub mit



      Sten Larsson wrote:
      [color=blue]
      > I have to code below - works great in IE and Opera, but does not work
      > at all in Firefox / Netscape. Any ideas?
      >
      > The problem is that nothing happens when clicking printer friendly.[/color]

      Check the JavaScript console of Firefox/Netscape and you will see what
      happens, your script causes an error.
      [color=blue]
      > ...
      > function onPrint()
      > {
      > window.printFor m.submit();[/color]

      You need
      document.forms. printForm.submi t();
      [color=blue]
      > <a href="#" onClick="onPrin t(); return false;">printer friendly</a>
      > </td>
      > ...
      > <form name="printForm " ction="/xasp?print=on" method=post>[/color]


      --

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

      Comment

      Working...