Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with learning form()

    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

    Code:
    <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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,302
    Thanks
    203
    Thanked 2,562 Times in 2,540 Posts
    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.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New Coder
    Join Date
    Jan 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,631 Times in 4,594 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    Jan 2012
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So I'd like to clarify some information with you on my knowledge of this;
    Code:
    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?

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,631 Times in 4,594 Posts
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •