TehMadHatter
01-26-2012, 07:20 AM
I am currently trying to learn the <form> object.
Now I have done some things within <form> like setting up text fields with submit buttons, etc..
But now on this part of the course it is showing properties I think, within the decleration of the <form> such as shown below
<FORM METHOD="POST" ACTION="/cgi-bin/correct.pl" onSubmit="return false;">
Could someone explain to me what that ACTION="/cgi-bin/corrct.pl" is for along with the onSubmit="return false;" ??
I'd like an explanation of the properties of <form> if you could please.
Philip M
01-26-2012, 07:37 AM
You ought to Google for this sort of question.
The required action attribute of a form specifies where to send the form-data when a form is submitted. return false suppresses this action. The form will never be submitted. Normally a validation script is used which if the validation fails returns false, to prevent the form from being submitted.
The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute). The form-data can be sent as URL variables (with method="get") or as HTTP post (with method="post").
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
TehMadHatter
01-28-2012, 10:22 PM
If return false suppreses this, then why do I even need to put the ACTION part?
Why is it even there in this code if it's not actually submiting it?
Old Pedant
01-28-2012, 11:09 PM
I suspect your book is just showing you format.
However... If the user has JavaScript disabled, then the return false will have no effect and so the from *will* submit to the server side page specified.
TehMadHatter
01-29-2012, 01:20 AM
So I'd like to clarify some information with you on my knowledge of this;
ACTION="/cgi-bin/correct.pl" onSubmit="return false;">
action being, where the submitted information is sent?
onSubmit meaning when the information is submitted, what to do?
Old Pedant
01-29-2012, 03:22 AM
Yes. Yes.
But, again, onsubmit is ignored if JS is disabled.
(As are all "onxxx" event handlers, of course.)
Of course, a <form> that doesn't submit is essentially useless in a non-JavaScript environment. Since the only action that a <form> in non-JS *can* do is get submitted.