submit question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt

    submit question

    When the user click the submit button in myform.asp, then it will
    invoke the
    javascript to check the form data. I want to know if we need
    document.myform .submit(); ?? Because even I comment it out,
    formresponse.as p
    could still get the form data.

    //myform.asp
    <script type="text/javascript">
    function checkformdata()
    { //etc...
    document.myform .submit();
    }
    </script>

    <form name="myform" action="formres ponse.asp" method="post"
    onsubmit="check formdata()">
    //controls etc...
    </form>

    //formresponse.as p
    <%= Request.Form %>
  • Hywel Jenkins

    #2
    Re: submit question

    In article <ba8a039e.04050 30634.cf9d968@p osting.google.c om>, Matt
    says...[color=blue]
    > When the user click the submit button in myform.asp, then it will
    > invoke the
    > javascript to check the form data. I want to know if we need
    > document.myform .submit(); ?? Because even I comment it out,
    > formresponse.as p
    > could still get the form data.
    >[/color]

    Didn't you multi-post this to alt.html? Naughty boy.

    --
    Hywel I do not eat quiche


    Comment

    • kaeli

      #3
      Re: submit question

      In article <ba8a039e.04050 30634.cf9d968@p osting.google.c om>,
      jrefactors@hotm ail.com enlightened us with...[color=blue]
      > When the user click the submit button in myform.asp, then it will
      > invoke the
      > javascript to check the form data. I want to know if we need
      > document.myform .submit();[/color]

      No; it's redundant in the code you posted.
      Remove it.

      --
      --
      ~kaeli~
      You feel stuck with your debt if you can't budge it.



      Comment

      • Brian Genisio

        #4
        Re: submit question

        Matt wrote:
        [color=blue]
        > When the user click the submit button in myform.asp, then it will
        > invoke the
        > javascript to check the form data. I want to know if we need
        > document.myform .submit(); ?? Because even I comment it out,
        > formresponse.as p
        > could still get the form data.
        >
        > //myform.asp
        > <script type="text/javascript">
        > function checkformdata()
        > { //etc...
        > document.myform .submit();
        > }
        > </script>
        >
        > <form name="myform" action="formres ponse.asp" method="post"
        > onsubmit="check formdata()">
        > //controls etc...
        > </form>
        >
        > //formresponse.as p
        > <%= Request.Form %>[/color]

        Using submit() is only for when you want to submit something through a
        different means. Say, for instance, you want an anchor link to submit a
        form. You can set onClick="docume nt.myform.submi t()".

        When the onSubmit callback is called, it is called either because
        someone pressed the submit button, or submit() was called.

        Note that you should return something from your function, and return it
        to the onSubmit handler. Returning true tells the form to keep going,
        but returning false tells the form not to send. For instance, you might
        do something like this:

        <script type="text/javascript">
        function checkFormData()
        {
        // etc...
        if(dataValid)
        return true;
        else
        {
        alert("You are a naughty boy");
        return false;
        }
        }

        <FORM ... onSubmit="retur n checkFormData() ">

        Brian

        Comment

        Working...