www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Form not Submitting

  1. #1
    Join Date
    Sep 2009
    Posts
    172

    resolved [RESOLVED] Form not Submitting

    All,
    I have the following code:
    Code:
    <form name="calculate" id="calculate" method="post" action="">
    <table width="539" border="1" cellspacing="5" cellpadding="5">
    <tr>
    <td width="65">One:</td>
    <td width="433"><input type="text" name="one" /></td>
    </tr>
    <tr>
    <td>Two:</td>
    <td><input type="text" name="two" /></td>
    </tr>
    <tr>
    <td>Total:</td>
    <td><input type="text" name="total" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Calculate Savings" onClick="calculatenow(this.calculate);"/></td>
    </tr>
    </table>
    </form>
    Here is the calculate function:
    Code:
    <script language="text/javascript">
    function calculatenow(obj){
    alert('it works');
    }
    </script>
    It's not showing me the alert. I'm just trying to get that part to show it works. However, what I'm trying to do is add up the values in one and two and the based on adding those two up and then placing that total in the total field. Any ideas on how to do this?

    Thanks in advance.

  2. #2
    Join Date
    May 2010
    Posts
    213
    Because language is not text/javascript. Type is text/javascript.
    And here's the whole example that works (id's on input fields needed)

    Code:
    <form name="calculate" id="calculate" method="post" action="">
    <table width="539" border="1" cellspacing="5" cellpadding="5">
    <tr>
    <td width="65">One:</td>
    <td width="433"><input type="text" name="one" id="one"/></td>
    </tr>
    <tr>
    <td>Two:</td>
    <td><input type="text" name="two" id="two"/></td>
    </tr>
    <tr>
    <td>Total:</td>
    <td><input type="text" name="total" id="total"/></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><input type="button" name="Submit" value="Calculate Savings" onClick="calculatenow();"/></td>
    </tr>
    </table>
    </form>
    
    <script type="text/javascript">
    function calculatenow(obj){
    	var a = parseInt(document.getElementById('one').value) + parseInt(document.getElementById('two').value);
    	document.getElementById('total').value = a.toString();
    }
    </script>
    i love easter eggs
    (if you got any creative easter eggs, send me a PM)

  3. #3
    Join Date
    Sep 2009
    Posts
    172
    Thanks, that did the trick. Appreciate the help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles