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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy I need help on a javascript/html problem!

    here is part of my code:
    ...
    <script language="Javascript">

    function Calc(Atext, Btext, form)
    {
    ...
    }
    </script>

    ...
    <form action="" name="Calculator" METHOD="post" onsubmit="return Calc(this.Amt.value, this.APR.value, this)" style="z-index: 1; width: 565px; height: 47px; position: absolute; top: 128px; left: 309px">
    ...

    The form takes the values in the Amt and APR textboxes and automatically formats them. Once you click the "Calculate" button (a graphic image), the program calls the onsubmit to the Calc function, which then properly validates the text and processes it. The idea here was to convert the answer from a text answer (i.e., "$125.00") into pictures. I have the individual picture files linked. Everything works right...

    ...except...

    Not long after the answer appears on the screen, the page reloads or refreshes or whatever. I've been pulling my hair out on this! I want the page to stay up once everything's complete, and make no changes at all until (unless) the user clicks another button. Can anyone help?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,111
    Thanks
    75
    Thanked 4,336 Times in 4,302 Posts
    Are you making sure that your Calc( ) function *ALWAYS* returns false??? If not, the submit of the <form> will go ahead and take place.

    Maybe an easier way to make sure this doesn't happen is via:
    Code:
    <form action="" name="Calculator" METHOD="post" 
              onsubmit="Calc(this.Amt.value, this.APR.value, this); return false;"
              style="z-index: 1; width: 565px; height: 47px; position: absolute; top: 128px; left: 309px">


  •  

    Tags for this Thread

    Posting Permissions

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