From: Gregor Kofler on
Scott Sauyet meinte:
> On Jan 21, 3:28 pm, cate <catebekens...(a)yahoo.com> wrote:
>> I have something like this (trimmed down)
>>
>> <form id="aform",method="post">
>> <input type="submit" id="butOne", value="butOne">
>> <textarea id="tx1"></textarea>
>> <input type="submit" id="butTwo" value="butTwo">
>> <textarea id="tx2"></textarea>
>> </form>
>
> One thing people want you to notice about the HTML is that you haven't
> closed your input tags

They won't.

>> I want to intercept the submit action on butOne, so I tried this
>>
>> <input type="button" id="butOne", value="butOne" onClick="checkStuff
>> (this);">
>
> Usually you will want to end the inline handler with "return false;"
> If not, your code will run and then the form will be submitted, even
> if you would rather it didn't. And the attribute name is
> "onclick" (all lower-case);
>
> onclick="checkStuff(this); return false;"

Which won't cancel a submit with button-type input elements.

> One problem with "type='button'" is that this will not do anything for
> users without Javascript or for those with Javascript disabled. You
> can do the same thing with "type='submit'" without those problems.
>
>> ... and added the js
>>
>> function checkStuff(e) {
>> test test test
>> document.getElementById('aform').submit();
>>
>> }
>
> You might also want to consider removing the inline handler, and
> running something after the document is loaded to connect a click
> handler to the button or a submit handler to the form.
>
> window.onload = function() {
> var aForm = document.getElementById("aform");
> if (aForm) {
> aForm.onsubmit = function() {
> var result = runMyTests();
> return result;
> }
> }
> }

There's only a body.onload... Besides I can't see any advantage of this
approach, at least not in this specific case.

Gregor


--
http://www.gregorkofler.com
From: Asen Bozhilov on
Scott Sauyet <scott.sau...(a)gmail.com> wrote:

>     window.onload = function() {
>         var aForm = document.getElementById("aform");
>         if (aForm) {
>             aForm.onsubmit = function() {
>                 var result = runMyTests();
>                 return result;
>             }
>         }
>     }

You make a circular reference pattern.

VO -> aForm -> onsubmit -> AFE[[scope]] -> VO

JScript implementation before version 5.8 have trouble with garbage
collection especially, when deal with host objects.

<URL: http://www.jibbering.com/faq/faq_notes/closures.html#clMem />
<URL: http://blogs.msdn.com/ericlippert/archive/2003/09/17/53038.aspx /
>


You should break circular reference:

aForm.onsubmit = function(){
};
aForm = null;

Regards.
From: Scott Sauyet on
On Jan 21, 4:49 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
wrote:
>>     window.onload = function() {
>
> You're really the worst kind of wannabe.  Please have the kindness
> and be quiet until you got your facts right.  Thank you in advance.
>
> OP: Don't listen to Scott.

OP: Instead, listen to all the useful advice Thomas has given so far.
Oh wait, all he has offered is non-specific criticism of your markup,
and a partially-valid critique of my suggestions.

-- Scott
From: Scott Sauyet on
On Jan 21, 5:14 pm, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
> Scott Sauyet <scott.sau...(a)gmail.com> wrote:
>
> You make a circular reference pattern.
>
> VO -> aForm -> onsubmit -> AFE[[scope]] -> VO
> [ ... ]
> You should break circular reference:
>
> aForm.onsubmit = function(){};
> aForm = null;

Absolutely correct. Thank you for pointing it out.

-- Scott
From: Richard Cornford on
On Jan 22, 4:29 pm, Scott Sauyet wrote:
> On Jan 21, 4:49 pm, Thomas 'PointedEars' Lahn wrote:
>
>>> window.onload = function() {
>
>> You're really the worst kind of wannabe. Please have the
>> kindness and be quiet until you got your facts right.
>> Thank you in advance.
>
>> OP: Don't listen to Scott.
>
> OP: Instead, listen to all the useful advice Thomas has given
> so far. Oh wait, all he has offered is non-specific criticism
> of your markup, and a partially-valid critique of my suggestions.

Assuming the above is not part of a "partially-valid critique" of your
suggestions (as it seems to be a general comment rather than being
about any suggestions made), which part of his "critique" was not
valid?

Your comments in relation to the mark-up were absolutely wrong (both
in terms of what 'people' were trying to draw attention towards and
the technical aspects of your suggested changes), and Thomas' comments
on it were spot-on. His comments on the "return false;" suggestions
may have started out with a slightly subjective assertion (if one that
I agree with), but the observation that <input type="button"> elements
don't have a default action to be cancelled by such code was making a
valid point.

I do not agree with the section you quoted above. VK is easily "the
worst kind of wannabe" (combining, as he does, a self-created fantasy
understanding of javascript, an inability to understand when he is
shown to be wrong and an approach to reasoning that rarely achieves
lucidity) (sorry, I could not think of a way of expressing that which
does imply that you are also a "wannabe", which is not sort of
terminology that I would normally use, and strikes me as a very
premature conclusion). And being quiet until you get your facts right
would be a very bad idea, and generally unwelcome. As a learning
exercise, it is best to say what you think about the subject and then
listen to the criticism that receives. And it is in the discussions
that follow from those exchanges that much of the interesting content
on the group can be found.

Richard.