onsubmit

C

Chris

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
 
A

Adrienne Boswell

Gazing into my crystal ball I observed Chris <[email protected]>
writing in @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.
 
J

Jeff

Chris said:
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
 
T

Toby A Inkster

Jeff said:
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/
 
D

David Dorward

Toby said:
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.
 
T

Toby A Inkster

David said:
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/
 
D

David Dorward

Toby said:
David Dorward wrote:

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.
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Tue, 15 Jan 2008 17:01:04
GMT David Dorward scribed:
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.
 
J

Jeff

David said:
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
 
T

Toby A Inkster

Neredbojias said:
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/
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top