Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15092

Re: submit()

From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: submit()
Date 2012-07-18 09:09 +0300
Organization A noiseless patient Spider
Message-ID <ju5jvj$7qj$1@dont-email.me> (permalink)
References <qm7a081tvl82u7cbifdqebuog7bkbhi7v4@4ax.com> <ju3db0$q56$1@dont-email.me> <mhqa08pgc6hu3vh445s163f6k25tda3tv3@4ax.com>

Show all headers | View raw


2012-07-17 16:51, Swifty wrote:

> The request was for a calendar, which I delivered as a simple HTML
> table, with a cell for each day. A new entry for a particular day is
> created by a click on the cell's background. I'm not certain, but I
> suspect this more or less makes JavaScript mandatory.

It depends on the interpretation and context. If there are no other 
cells, you can make the input buttons cover the entire area of the cell.

> I wonder if I can put my <TD> inside a <BUTTON></BUTTON> sequence?

You can't, but you can use <td><input type=submit></td> with 
cellspacing=0 on the <table> element.

> And I still haven't
> recovered from IE6's implementation of <BUTTON>!

Me neither. But there's always <input type=submit>.

Of course, if you want nice square cells with no resemblance of a 
button, then you need something else. But you can style <input 
type=button> that way, e.g.

input[type=submit] {
    display: block;
    width: 3em;
    height: 3em;
    border: none;
}

I'm not saying that you shouldn't use <td onclick> or equivalent; just 
that it is possible to do things like clickable calendars so that clicks 
trigger form submission, thus providing a natural way to implement 
server-side backup for the functionality.

> I was raised on:
> <form name=monthForm ...>
> ...
> onclick="document.monthForm.submit()">
>
> ... and somehow, I cannot see the id attribute as superior.

It's more of a principle than practice. By essence, name attributes are 
for naming, allowing the same name to be assigned to several elements, 
whereas id attributes are unique by definition. It's not really the name 
but the type of the attribute that matters. In HTML, the id attribute is 
declared as ID, which means unique identifier, so an HTML validator will 
check for the uniqueness

> It certainly involves a lot more typing;

There's always jQuery, which lets you save several keystrokes at the 
cost of a few standard lines in your code as well as the overhead of 
loading and parsing the library file. :-) But seriously, you *could* 
e.g. slap just

<script src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

into the <head> element and use

onclick = "$('#monthForm').submit()"

when you have <form id="monthForm">.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

submit() Swifty <steve.j.swift@gmail.com> - 2012-07-17 09:36 +0100
  Re: submit() Martin Honnen <mahotrash@yahoo.de> - 2012-07-17 11:45 +0200
    Re: submit() Tim Streater <timstreater@greenbee.net> - 2012-07-17 11:36 +0100
    Re: submit() Martin Honnen <mahotrash@yahoo.de> - 2012-07-18 19:12 +0200
  Re: submit() SAM <stephanemoriaux.NoAdmin@wanadoo.fr.invalid> - 2012-07-17 12:03 +0200
  Re: submit() "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-07-17 13:04 +0300
    Re: submit() Swifty <steve.j.swift@gmail.com> - 2012-07-17 14:51 +0100
      Re: submit() "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-07-18 09:09 +0300
        Re: submit() Swifty <steve.j.swift@gmail.com> - 2012-07-19 17:27 +0100

csiph-web