From: cate on
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>

I want to intercept the submit action on butOne, so I tried this

<input type="button" id="butOne", value="butOne" onClick="checkStuff
(this);">

.... and added the js

function checkStuff(e) {
test test test
document.getElementById('aform').submit();
}

Problem is that the two textarea don't seem to post. Go back to
type=submit and everything seems fine.

Thank you.
From: Thomas 'PointedEars' Lahn on
cate 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>

Ahh -- yes. Pray learn HTML first.

<http://validator.w3.org/>


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Gregor Kofler on
cate meinte:
> 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>

Creative markup.

> Problem is that the two textarea don't seem to post. Go back to
> type=submit and everything seems fine.

Whatever that means...

> Thank you.

You are welcome.

Gregor


--
http://www.gregorkofler.com
From: Scott Sauyet on
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

> 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;"

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;
}
}
}

Good luck,

-- Scott
From: Thomas 'PointedEars' Lahn on
Scott Sauyet wrote:

> cate 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

Nobody knowing what they are talking about would say such an incredibly
stupid thing. The "input tags" are closed (there's the TAGC delimiter,
`>'). The INPUT elements, if this is HTML, are fine except for the comma;
in fact, since their content model is EMPTY, the </input> _end_ tag is
*forbidden*.

>> 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;"

No, usually you would want to cancel the `submit' event of the form
instead. If, and only if, the control would cause form submission by
default, which this one does NOT.

> 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() {

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.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)