No, *I* confused us both I think... I was talking about the HTML
<button> element, not the <input type="button"> element... Seems odd
they wouldn't be equivalent, but still!
L.
Frank W. Zammetti wrote:
You almost had me convinced Laurie :)
<html>
<head>
</head>
<body>
<form name="f" action="http://www.google.com/search">
<input type="hidden" value="en" name="hl">
<input name="q">
<input type="button" value="I'm Feeling Lucky" name="btnI">
</form>
</html>
Clicking on the button DOES NOT submit the form. Interestingly though,
and I don't think I was aware of this actually, hitting return DOES
submit it. This seems wrong to me... To my way of thinking a "button"
should NOT submit a form without scripting involved, but it does when
the keyboard is used. Not the mouse though. I tried this in both IE 6
and FF 1.0, both behave the same way, so no apparent browser
peculiarities. As one would expect, changing "button" to "submit" will
cause the form to be submitted when clicked as usual.
Also, if you change the above "button" to a "submit", and add two other
"buttons" with values, note that they DO NOT get submitted. At least
that is true in IE, I didn't try it in FF, but I would expect to see the
same thing. Lastly, if you put two "submits" in there, only the clicked
one gets transmitted, but that's what we expect I think.
Could the difference in functionality between clicking and pressing
return have confused us both? :)
Frank
Laurie Harper wrote:
Sorry, but this just isn't true... At least when there's no Javascript
involved, a button acts just like a 'submit'-type input: clicking it
submits the form, and a request parameter is submitted corresponding
to the button that was clicked (and only the one that was clicked).
Buttons may interact with Javascript differently than submit inputs
(I'm not convinced of that, though) but they certainly do submit the
form normally.
L.
Frank W. Zammetti wrote:
Laurie Harper wrote:
Catherine wrote:
3. <html:button property="submitAction" value="Add Property"
onclick="javascript:checkProp()">
This is my real problem. I have a single selection dropdown
menu which contains the allowed properties of the object. When user
selects a property and clicks the Add Property button, I call
checkProp() to check if it already added to the object. If yes, I
alert user and don't submit form; if no, I call form.submit(). I
found that submitAction="" if the form is submitted this way. I
tried to do form.submitAction.value = "Add Property" before
submit(), but that didn't help. How can I pass that value?
If you define an onclick event handler then, as far as I understand
it, clicking the button will execute the event handler first and
then submit the form second *if* the event handler returns true. So,
if your checkProp() function returns true the form would be
submitted as if you hadn't had an onclick handler; if it returns
false, the form will not be submitted.
Almost :)
Note that an <input type="button"> (html:button> is different from an
<input type="submit"> (html:submit). The button won't submit the
form at all unless you write script to call form.submit(), it's just
a button with no inherent functionality, as far as for form goes.
What you'd want to do is hook the onSubmit event of an actual submit
button. There, you can call your validation code and as you say,
return true to allow the form submission to go through, false to
abort it.
I *think* the problem you are seeing Catherine, and I'm saying this
from memory so I may not have it quite right, is that button values
aren't submitted with the form unless it was an actual submit
button. So, you would have to have a hidden form field named
submitAction that you populate via script if the form isn't being
submitted with an actual submit button.
For case 2, you're specifying the URL to load in the Javascript so
you're not submitting the form. Therefore your form properties
aren't included in the request. I'm not sure how you get the onclick
handler to submit the form as if the handler weren't there, my
Javascript fu isn't that good yet ;-)
That's correct, in case 2 the form isn't being submitted, so no
parameters are sent. Basically, there is two mechanisms by which the
form can get submitted: (a) the user clicks a submit button, or (b)
some script calls submit() on the form. In the case of (a), you can
hook the onsubmit event and call some function, and as Laurie said,
return true to allow the form to be submitted, or false to stop it.
In the case of (b), you hook the onclick event of a plain old button
and you take on complete responsibility for submitting the form, it
will never happen automatically in that case. In both cases it might
be easier to have some script set a hidden field with the appropriate
submitAction value, that way you have complete control over it.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]