Results 1 to 4 of 4

Thread: How can I get my "onsubmit" functions to be executed?

  1. #1
    Guest

    Smile

    Hi!

    I have this form on my page, with an "onsubmit" function". Now I don't use a submit button to have the form submitted, but an image. So the code goes something like this (the file validationfunctions.js contains a function called validatecontents() ):


    <script language="javascript">
    <!--
    function submittheform()
    {
    document.myform.submit();
    }
    //-->
    </script>
    <script language="javascript" src="validationfunctions.js">
    </script>
    .
    .
    <form name = "myform" action="nextpage.asp" onsubmit="validatecontents()">
    .
    .
    <a href="javascript:submittheform()"><img src="image.jpg"></a>
    </form>


    Now when I click the image, it submits the form, without running the validatecontents-function first. Why? And how can I make it so it DOES run that function first?

    Many thanx!

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Posts
    266
    try this
    <form name = "myform" action="nextpage.asp" OnSubmit="return validatecontents()">

    Also return true from the function validatecontents()

  3. #3
    Guest
    Hi!

    I'm sorry, in my page the form declaration is like the solution you gave, but when submitting the problem here, I just typed the code in from heart, and forgot to type the return statement.

    So... the problem remains unsolved..

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Why not call the validation function from your submittheform() function?

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width