onsubmit

Discussion in 'HTML' started by Chris, Jan 15, 2008.

  1. Chris

    Chris Guest

    I have two onsubmits I'd like to include in my <FORM...> tag and
    wanted to know before I go through the work of putting in all the code
    if this is even allowed. And if not then how should I be calling it?

    <FORM action="test.cgi" method="POST" onsubmit="csave()"
    onSubmit="return checkform()">

    Thanks,
    Chris
    Chris, Jan 15, 2008
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed Chris <>
    writing in news:91776f54-5df8-42a3-a381-0f521ecc5791
    @u10g2000prn.googlegroups.com:

    > I have two onsubmits I'd like to include in my <FORM...> tag and
    > wanted to know before I go through the work of putting in all the code
    > if this is even allowed. And if not then how should I be calling it?
    >
    ><FORM action="test.cgi" method="POST" onsubmit="csave()"
    > onSubmit="return checkform()">
    >
    > Thanks,
    > Chris
    >


    The way to do it is to name the submit buttons, <input type="submit"
    name="submit1" value="Submit 1">
    and
    <input type="submit" name="submit2" value="Submit 2">

    Then you check server side which submit got pressed.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Jan 15, 2008
    #2
    1. Advertising

  3. Chris

    Jeff Guest

    Chris wrote:
    > I have two onsubmits I'd like to include in my <FORM...> tag and
    > wanted to know before I go through the work of putting in all the code
    > if this is even allowed. And if not then how should I be calling it?
    >
    > <FORM action="test.cgi" method="POST" onsubmit="csave()"
    > onSubmit="return checkform()">


    I'm going answer this, even though it's a rather dumb question and
    off topic here, because I want you to have an answer. And I think most
    here will misread the question. Next time post to comp.lang.javascript
    after reading the FAQ there.

    First, you can just call one javascript from inside the other, that's
    the best way to do that.

    otherwise:

    <form onsubmit="csave();return checkForm()"...

    You don't want two onsubmits, lowercase is correct here as it is for
    form and action.

    Jeff

    >
    > Thanks,
    > Chris
    Jeff, Jan 15, 2008
    #3
  4. Jeff wrote:

    > You don't want two onsubmits, lowercase is correct here as it is for
    > form and action.


    In XHTML, yes; in HTML, the case of element and attribute names does not
    matter, but using camelCase is not unusual for the event handling
    attributes, to draw parallels with the usual Javascript coding style.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 15 days, 23:32.]

    GPS & Cameras
    http://tobyinkster.co.uk/blog/2008/01/14/gps-cameras/
    Toby A Inkster, Jan 15, 2008
    #4
  5. Toby A Inkster wrote:
    > In XHTML, yes; in HTML, the case of element and attribute names does not
    > matter, but using camelCase is not unusual for the event handling
    > attributes, to draw parallels with the usual Javascript coding style.


    Ironically, while camelCase is the usual JS style, in the case of event
    handlers, the DOM methods are lower case.

    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
    David Dorward, Jan 15, 2008
    #5
  6. David Dorward wrote:

    > Ironically, while camelCase is the usual JS style, in the case of event
    > handlers, the DOM methods are lower case.


    Indeed. IIRC, *all* DOM properties that have a one-to-one mapping to HTML
    attributes are lower case.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 16 days, 2:35.]

    GPS & Cameras
    http://tobyinkster.co.uk/blog/2008/01/14/gps-cameras/
    Toby A Inkster, Jan 15, 2008
    #6
  7. Toby A Inkster wrote:
    > David Dorward wrote:


    >> Ironically, while camelCase is the usual JS style, in the case of event
    >> handlers, the DOM methods are lower case.

    >
    > Indeed. IIRC, *all* DOM properties that have a one-to-one mapping to HTML
    > attributes are lower case.


    Consistancy would be nice, but sadly ... *.className, meta.httpEquiv,
    body.bgColor, and so on.



    --
    David Dorward
    http://dorward.me.uk/
    http://blog.dorward.me.uk/
    David Dorward, Jan 15, 2008
    #7
  8. Chris

    Neredbojias Guest

    Well bust mah britches and call me cheeky, on Tue, 15 Jan 2008 17:01:04
    GMT David Dorward scribed:

    > Toby A Inkster wrote:
    >> David Dorward wrote:

    >
    >>> Ironically, while camelCase is the usual JS style, in the case of
    >>> event handlers, the DOM methods are lower case.

    >>
    >> Indeed. IIRC, *all* DOM properties that have a one-to-one mapping to
    >> HTML attributes are lower case.

    >
    > Consistancy would be nice, but sadly ... *.className, meta.httpEquiv,
    > body.bgColor, and so on.


    Dont forget document.getElementById("...")... That's the one I just luuuv
    typing.

    --
    Neredbojias
    Riches are their own reward.
    Neredbojias, Jan 15, 2008
    #8
  9. Chris

    Jeff Guest

    David Dorward wrote:
    > Toby A Inkster wrote:
    >> David Dorward wrote:

    >
    >>> Ironically, while camelCase is the usual JS style, in the case of event
    >>> handlers, the DOM methods are lower case.

    >> Indeed. IIRC, *all* DOM properties that have a one-to-one mapping to HTML
    >> attributes are lower case.

    >
    > Consistancy would be nice, but sadly ... *.className, meta.httpEquiv,
    > body.bgColor, and so on.


    I rather like it that way as those generally have dashes where the camel
    is.

    border-width -> borderWidth
    background-color ->backgroundColor

    It would be hard to program elsewise.

    Jeff
    >
    >
    >
    Jeff, Jan 15, 2008
    #9
  10. Neredbojias wrote:

    > Dont forget document.getElementById("...")... That's the one I just
    > luuuv typing.


    That's not a 1:1 equivalent to an HTML attribute though.

    ..className and .httpEquiv differ from the heuristic that I mentioned
    earlier (all DOM properties that have a one-to-one mapping to HTML
    attributes are lower case) out of necessity:

    * "class" is a reserved word in JavaScript.

    * "http-equiv" contains a hyphen which would be interpreted
    as subtraction.


    You are right about .bgColor though. How annoying. Come to think of
    it, .aLink,.vLink and .accessKey. Most of these correspond to deprecated
    attributes though.

    --
    Toby A Inkster BSc (Hons) ARCS
    [Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
    [OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 16 days, 21:12.]

    Gnocchi all'Amatriciana al Forno
    http://tobyinkster.co.uk/blog/2008/01/15/gnocchi-allamatriciana/
    Toby A Inkster, Jan 16, 2008
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U25vd2JhbmsgSmlt?=

    Form-level onSubmit handler

    =?Utf-8?B?U25vd2JhbmsgSmlt?=, Feb 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    401
    Peter Blum
    Feb 21, 2004
  2. Replies:
    3
    Views:
    1,118
    bruce barker
    Feb 25, 2004
  3. =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=

    Re: Add onSubmit To Form?

    =?Utf-8?B?Q3Jpc3RpYW4gQ2FybHNzb24=?=, May 25, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    668
    Steven Cheng[MSFT]
    May 27, 2004
  4. Joeyej
    Replies:
    0
    Views:
    7,959
    Joeyej
    Jun 4, 2004
  5. Mark Rae

    Re: onsubmit Event in aspx page.

    Mark Rae, Aug 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    401
    Mark Rae
    Aug 17, 2004
Loading...

Share This Page