document.form.submit()

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

    document.form.submit()

    Heres my problem:

    <a href="javascrip t:void(document .buysell.submit ())" target="_parent "
    onMouseOver="MM _swapImage('mem bers','','image s/membersf2.gif', 1)"
    onMouseOut="MM_ swapImgRestore( )"><img src="images/members.gif"
    alt="Back to members page" name="members" width="270" height="25"
    border="0"></a>

    I get the error "document.buyse ll" is null or not an object, but my
    form name is buysell and when using the submit button, which is not
    called "submit", everything submits fine....
    please help,
    Chris.
  • Evertjan.

    #2
    Re: document.form.s ubmit()

    Chris wrote on 16 dec 2003 in comp.lang.javas cript:[color=blue]
    > <a href="javascrip t:void(document .buysell.submit ())" target="_parent "
    > onMouseOver="MM _swapImage('mem bers','','image s/membersf2.gif', 1)"
    > onMouseOut="MM_ swapImgRestore( )"><img src="images/members.gif"
    > alt="Back to members page" name="members" width="270" height="25"
    > border="0"></a>
    >
    > I get the error "document.buyse ll" is null or not an object, but my
    > form name is buysell and when using the submit button, which is not
    > called "submit", everything submits fine....[/color]

    document.forms. buysell.submit( )

    I would put the target declaration in the <form >
    and use no <a> at all:

    <img
    onclick="docume nt.forms.buysel l.submit()"
    onMouseOver=".. ."
    onMouseOut="... "
    src="images/members.gif"
    alt="Back to members page"
    name="members" id="members"
    width="270" height="25"[color=blue]
    >[/color]

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • kaeli

      #3
      Re: document.form.s ubmit()

      In article <c2870fa6.03121 52033.5649a61d@ posting.google. com>,
      christopherhebr ard@hotmail.com enlightened us with...[color=blue]
      > Heres my problem:
      >
      > <a href="javascrip t:void(document .buysell.submit ())"[/color]

      First of all, void is just that - void. No params.
      If you MUST use this because you have to support old browsers, use
      <a href="javascrip t:document.form s["buysell"].submit();

      If you support only newer browsers, do this the right way.
      <a href="#" onClick="docume nt.forms['buysell'].submit;return false;"

      Keep in mind about 5% of US users in general (last I read on some IT
      site, anyway) do not have JS enabled browsers. For them, this will not
      submit any form at all. You should really have something in that href
      for people with no JS if this is for an internet site.
      [color=blue]
      > target="_parent "
      > onMouseOver="MM _swapImage('mem bers','','image s/membersf2.gif', 1)"
      > onMouseOut="MM_ swapImgRestore( )"><img src="images/members.gif"
      > alt="Back to members page" name="members" width="270" height="25"
      > border="0"></a>
      >
      > I get the error "document.buyse ll" is null or not an object, but my
      > form name is buysell and when using the submit button, which is not
      > called "submit", everything submits fine....[/color]


      I notice you reference "parent" as the target. Is the form on the same
      page as this script? If not, you should reference it as
      top.frames["framename"].document.forms["formname"]
      to be sure the script can "see" it.

      --
      --
      ~kaeli~
      Murphy's Law #2000: If enough data is collected, anything
      may be proven by statistical methods.



      Comment

      • Grant Wagner

        #4
        Re: document.form.s ubmit()

        Chris wrote:
        [color=blue]
        > Heres my problem:
        >
        > <a href="javascrip t:void(document .buysell.submit ())" target="_parent "
        > onMouseOver="MM _swapImage('mem bers','','image s/membersf2.gif', 1)"
        > onMouseOut="MM_ swapImgRestore( )"><img src="images/members.gif"
        > alt="Back to members page" name="members" width="270" height="25"
        > border="0"></a>
        >
        > I get the error "document.buyse ll" is null or not an object, but my
        > form name is buysell and when using the submit button, which is not
        > called "submit", everything submits fine....
        > please help,
        > Chris.[/color]

        If you want something that looks like a link to submit a form, I
        recommend:

        <style type="text/css">
        ..submitLink {
        background-color: transparent;
        padding: 8px;
        border: 0px solid transparent;
        color: Blue;
        text-decoration: underline;
        cursor: pointer;
        cursor: hand;
        }
        ..submitLink:ac tive {
        border: 0px solid transparent;
        color: Red;
        }
        }
        </style>
        <form>
        <input type="submit" name="submitBtn " value="Order" class="submitLi nk" />

        </form>

        Certainly it isn't as pretty in Netscape 4 or Opera 6, but it's
        guaranteed to give you a usable submit button regardless of the browser
        being used (presuming the browser supports form and form submission).

        By the way, Opera 7.23 is *still* having problems with this design. With
        7.23, it now honors border requests on buttons, but it honors neither the
        cursor: nor the text-decoration: directives. Also, Opera 7.23 seems to
        support the :active pseudo-class, at least partially, it makes a valiant
        attempt to honor the border: directive, but it fails to do it correctly.

        --
        | Grant Wagner <gwagner@agrico reunited.com>

        * Client-side Javascript and Netscape 4 DOM Reference available at:
        *


        * Internet Explorer DOM Reference available at:
        *
        Gain technical skills through documentation and training, earn certifications and connect with the community


        * Netscape 6/7 DOM Reference available at:
        * http://www.mozilla.org/docs/dom/domref/
        * Tips for upgrading JavaScript for Netscape 7 / Mozilla
        * http://www.mozilla.org/docs/web-deve...upgrade_2.html


        Comment

        • Grant Wagner

          #5
          Re: document.form.s ubmit()

          Grant Wagner wrote:
          [color=blue]
          > padding: 8px;[/color]

          Remove this, I was just seeing if padding made a difference to Opera showing
          text-decoration: and left it in when I posted.

          --
          | Grant Wagner <gwagner@agrico reunited.com>

          * Client-side Javascript and Netscape 4 DOM Reference available at:
          * http://devedge.netscape.com/library/...ce/frames.html
          * Internet Explorer DOM Reference available at:
          * http://msdn.microsoft.com/workshop/a...ence_entry.asp
          * Netscape 6/7 DOM Reference available at:
          * http://www.mozilla.org/docs/dom/domref/
          * Tips for upgrading JavaScript for Netscape 7 / Mozilla
          * http://www.mozilla.org/docs/web-deve...upgrade_2.html


          Comment

          • @SM

            #6
            Re: document.form.s ubmit()

            Grant Wagner a ecrit :[color=blue]
            >
            > If you want something that looks like a link to submit a form, I
            > recommend:
            >
            > <style type="text/css">
            > .submitLink {
            > background-color: transparent;
            > padding: 8px;
            > border: 0px solid transparent;
            > color: Blue;
            > text-decoration: underline;
            > cursor: pointer;
            > cursor: hand;
            > }
            > .submitLink:act ive {
            > border: 0px solid transparent;
            > color: Red;
            > }
            > }
            > </style>
            > <form>
            > <input type="submit" name="submitBtn " value="Order" class="submitLi nk" />
            >
            > </form>
            >
            > Certainly it isn't as pretty in Netscape 4[/color]

            over all in NN4
            who don't know "transparen t" and display a black color ! ! !
            By chance (or lucky) NN4 don't accept css on a button.

            so use :

            ..submitLink {
            padding: 8px;
            border: 0;
            color: blue;
            text-decoration: underline;
            cursor: pointer;
            cursor: hand;
            }
            ..submitLink:ac tive {
            /* border is the same and herited from above */
            color: Red;
            }

            [color=blue]
            > guaranteed to give you a usable submit button regardless of the browser
            > being used (presuming the browser supports form and form submission).[/color]

            -- ----
            @SM
            move away *OTEZ-MOI* from my reply url

            Comment

            • @SM

              #7
              Re: document.form.s ubmit()

              Chris a ecrit :[color=blue]
              >
              > Heres my problem:
              >
              > <a href="javascrip t:void(document .buysell.submit ())" target="_parent "[/color]

              <a href="javascrip t:void()" target="_parent "

              or

              <a href="document. forms['buysell'].submit" target="_parent "
              onclick="return false;">

              I hope you want to replace the framed page displayed in
              main window ?

              Anyway, with these 3 codes anything will happen...
              (except on 2nd if JS is disabled)

              to get something :

              <a href="#" target="_parent "
              onclick="docume nt.forms['buysell'].target='frame2 ';
              document.forms['buysell'].submit(); return false;">


              -- -----
              @SM
              move away *OTEZ-MOI* from my reply url

              Comment

              • Chris

                #8
                Re: document.form.s ubmit()

                still doesnt work, but thanks for feedback anyway.

                Comment

                • Chris

                  #9
                  Re: document.form.s ubmit()

                  kaeli <tiny_one@NOSPA M.comcast.net> wrote in message news:<MPG.1a48c c8dad1492bb989a 09@nntp.lucent. com>...[color=blue]
                  > In article <c2870fa6.03121 52033.5649a61d@ posting.google. com>,
                  > christopherhebr ard@hotmail.com enlightened us with...[color=green]
                  > > Heres my problem:
                  > >
                  > > <a href="javascrip t:void(document .buysell.submit ())"[/color]
                  >
                  > First of all, void is just that - void. No params.
                  > If you MUST use this because you have to support old browsers, use
                  > <a href="javascrip t:document.form s["buysell"].submit();
                  >
                  > If you support only newer browsers, do this the right way.
                  > <a href="#" onClick="docume nt.forms['buysell'].submit;return false;"
                  >
                  > Keep in mind about 5% of US users in general (last I read on some IT
                  > site, anyway) do not have JS enabled browsers. For them, this will not
                  > submit any form at all. You should really have something in that href
                  > for people with no JS if this is for an internet site.
                  >[color=green]
                  > > target="_parent "
                  > > onMouseOver="MM _swapImage('mem bers','','image s/membersf2.gif', 1)"
                  > > onMouseOut="MM_ swapImgRestore( )"><img src="images/members.gif"
                  > > alt="Back to members page" name="members" width="270" height="25"
                  > > border="0"></a>
                  > >
                  > > I get the error "document.buyse ll" is null or not an object, but my
                  > > form name is buysell and when using the submit button, which is not
                  > > called "submit", everything submits fine....[/color]
                  >
                  >
                  > I notice you reference "parent" as the target. Is the form on the same
                  > page as this script? If not, you should reference it as
                  > top.frames["framename"].document.forms["formname"]
                  > to be sure the script can "see" it.
                  >
                  > --[/color]


                  ok so the form submits, well not really because its not updating data
                  so really the form is just refreshing... any ideas?

                  Comment

                  • kaeli

                    #10
                    Re: document.form.s ubmit()

                    In article <c2870fa6.03121 61902.6cbea28f@ posting.google. com>,
                    christopherhebr ard@hotmail.com enlightened us with...[color=blue]
                    >
                    >
                    > ok so the form submits, well not really because its not updating data
                    > so really the form is just refreshing... any ideas?
                    >[/color]

                    Then how do you know it isn't a problem on the server side?

                    The default action for a form is to submit to itself. Do you have an
                    action defined?

                    --
                    --
                    ~kaeli~
                    Do cemetery workers prefer the graveyard shift?



                    Comment

                    • Grant Wagner

                      #11
                      Re: document.form.s ubmit()

                      "@SM" wrote:
                      [color=blue]
                      > Grant Wagner a ecrit :[color=green]
                      > >
                      > > If you want something that looks like a link to submit a form, I
                      > > recommend:
                      > >
                      > > <style type="text/css">
                      > > .submitLink {
                      > > background-color: transparent;
                      > > padding: 8px;
                      > > border: 0px solid transparent;
                      > > color: Blue;
                      > > text-decoration: underline;
                      > > cursor: pointer;
                      > > cursor: hand;
                      > > }
                      > > .submitLink:act ive {
                      > > border: 0px solid transparent;
                      > > color: Red;
                      > > }
                      > > }
                      > > </style>
                      > > <form>
                      > > <input type="submit" name="submitBtn " value="Order" class="submitLi nk" />
                      > >
                      > > </form>
                      > >
                      > > Certainly it isn't as pretty in Netscape 4[/color]
                      >
                      > over all in NN4
                      > who don't know "transparen t" and display a black color ! ! !
                      > By chance (or lucky) NN4 don't accept css on a button.[/color]

                      In Netscape 4.78, I get a standard grey button with underlined text. Netscape
                      4.x certainly does honor a number of CSS attributes on <input> elements, and
                      does it consistently (although some of the behaviour is certainly not what you
                      would expect, it is consistent between Netscape 4.6x/4.7x clients, at least in
                      my experience).
                      [color=blue]
                      > so use :
                      >
                      > .submitLink {
                      > padding: 8px;[/color]

                      Remove this, it was part of testing to see if some aspect of the button was
                      preventing "text-decoration: underline;" from working properly in Opera 7.23.
                      [color=blue]
                      > border: 0;
                      > color: blue;
                      > text-decoration: underline;
                      > cursor: pointer;
                      > cursor: hand;
                      > }[/color]

                      "border: 0;" doesn't properly suppress the border in Opera 7.23. In fact,
                      neither does "border: none;", which is why I went with "border: 0px solid
                      transparent;". Which specific version of Netscape 4.x doesn't render this
                      correctly? I'd like to install it and use it for testing.
                      [color=blue]
                      > .submitLink:act ive {
                      > /* border is the same and herited from above */[/color]

                      Yes, it was included inadvertently from testing I was doing trying to suppress
                      the border in Opera 7.23 when the button is pressed, it should have been
                      removed in the final version.
                      [color=blue]
                      > color: Red;
                      > }[/color]

                      You know, considering how "standards compliant" Opera claims to be, it
                      certainly doesn't deal with some of these CSS issues even as adeptly as IE.

                      --
                      | Grant Wagner <gwagner@agrico reunited.com>

                      * Client-side Javascript and Netscape 4 DOM Reference available at:
                      *


                      * Internet Explorer DOM Reference available at:
                      *
                      Gain technical skills through documentation and training, earn certifications and connect with the community


                      * Netscape 6/7 DOM Reference available at:
                      * http://www.mozilla.org/docs/dom/domref/
                      * Tips for upgrading JavaScript for Netscape 7 / Mozilla
                      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


                      Comment

                      • @SM

                        #12
                        Re: document.form.s ubmit()

                        Grant Wagner a ecrit :

                        Some very interesting things.

                        I wanted only to precise :

                        My NN is NC 4.5 (on old Mac system 8.6)
                        so, I can't see what you say.

                        Opera I can use is 6,03 (not more)
                        it is an horror !

                        IE is 5.0 (a fiew better and badder than same on PC)

                        Comment

                        • Chris

                          #13
                          Re: document.form.s ubmit()

                          kaeli <tiny_one@NOSPA M.comcast.net> wrote in message news:<MPG.1a4a2 2d0b173cd19989a 0f@nntp.lucent. com>...[color=blue]
                          > In article <c2870fa6.03121 61902.6cbea28f@ posting.google. com>,
                          > christopherhebr ard@hotmail.com enlightened us with...[color=green]
                          > >
                          > >
                          > > ok so the form submits, well not really because its not updating data
                          > > so really the form is just refreshing... any ideas?
                          > >[/color]
                          >
                          > Then how do you know it isn't a problem on the server side?
                          >
                          > The default action for a form is to submit to itself. Do you have an
                          > action defined?
                          >
                          > --[/color]

                          because i am doing the server side code...
                          the form submits data fine when clicking the submit button...
                          I got document.forms['formname'].submit() to work for the form, but on
                          other forms it does not because there target is not "_parent" ...

                          Comment

                          • kaeli

                            #14
                            Re: document.form.s ubmit()

                            In article <c2870fa6.03121 71620.5d3333a@p osting.google.c om>,
                            christopherhebr ard@hotmail.com enlightened us with...[color=blue]
                            >
                            > because i am doing the server side code...
                            > the form submits data fine when clicking the submit button...
                            > I got document.forms['formname'].submit() to work for the form, but on
                            > other forms it does not because there target is not "_parent" ...
                            >[/color]

                            So specify the target in the form, not the javascript.

                            --
                            --
                            ~kaeli~
                            Why did kamikaze pilots wear helmets?



                            Comment

                            • Thomas 'PointedEars' Lahn

                              #15
                              Re: document.form.s ubmit()

                              kaeli wrote:
                              [color=blue]
                              > In article <c2870fa6.03121 52033.5649a61d@ posting.google. com>,
                              > christopherhebr ard@hotmail.com enlightened us with...[color=green]
                              >> Heres my problem:
                              >>
                              >> <a href="javascrip t:void(document .buysell.submit ())"[/color]
                              >
                              > First of all, void is just that - void. No params.[/color]

                              This is utter nonsense. It is the `void' special unary operator.
                              Its operand may be a paranthesed expression.
                              [color=blue]
                              > If you MUST use this because you have to support old browsers, use
                              > <a href="javascrip t:document.form s["buysell"].submit();[/color]

                              Using the `void' operator is correct here since the `submit()' method
                              could return a value which replaces then the current document. *Not*
                              using it is bordering to incorrect here, considering the intended use
                              of the `javascript:' URI scheme: To use the return value of an
                              expression as contents of a temporary HTML document.




                              PointedEars
                              --
                              My proposal is not a solution for the actual problem.
                              (Markus Ernst in cljs, <brkovq$hrr$1$8 302bc10@news.de mon.co.uk>)

                              Comment

                              Working...