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
    Dec 2003
    Location
    Sunderland, UK
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Functions in forms

    I am trying to make a page which wis sort of a budget planner,
    It works out people inputs and adds them up and shows the results live.
    But
    The entered information also needs to be saved to a mySQL db via php and a form however I have a script working either entering the data to the db or adding up the data with javascript but the moment i try to put the javascript withing the for so the info can be saved it wont work.

    how can I fix this,
    any help would be much aprichiated as I have hit a brick wall.

    I HAVE ATACHED THE WORKING JAVACRIPT BUT NEED TO KNOW HOW TO CHANGE IT TO PUT IT WITHIN A FORM AND STILL WORK.

    Thankyou,
    David
    gowans007@yahoo.com



    <html>
    <head>
    <script language="javascript">
    <!--
    function addIt(){
    var value1 = document.adder.in_sloan.value
    var value2 = document.adder.in_parent_cont.value
    var value3 = document.adder.in_pt_job.value
    var value4 = document.adder.in_other.value
    document.adder.output.value = parseFloat(value1) + parseFloat(value2) + parseFloat(value3) + parseFloat(value4)

    var value5 = document.adder.in_sloan2.value
    var value6 = document.adder.in_parent_cont2.value
    var value7 = document.adder.in_pt_job2.value
    var value8 = document.adder.in_other2.value
    document.adder.output2.value = parseFloat(value5) + parseFloat(value6) + parseFloat(value7) + parseFloat(value8)

    document.adder.finalout.value = parseFloat(value1) + parseFloat(value2) + parseFloat(value3) + parseFloat(value4) + parseFloat(value5) + parseFloat(value6) + parseFloat(value7) + parseFloat(value8)

    }
    //-->
    </script>
    </head>
    <body>

    <FORM NAME="adder">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td> </td>
    <td><table width="52%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><input name="in_sloan" type="text" onChange="addIt()" value=0 size=4>
    var1 </td>
    </tr>
    <tr>
    <td><input name="in_parent_cont" type="text" onChange="addIt()" value=0 size=4>
    var2 </td>
    </tr>
    <tr>
    <td><input name="in_pt_job" type="text" onChange="addIt()" value=0 size=4>
    var3</td>
    </tr>
    <tr>
    <td><input name="in_other" type="text" onChange="addIt()" value=0 size=4>
    var4 </td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td><input type="text" name="output" size="6">
    <strong> tot </strong></td>
    </tr>
    </table></td>
    <td> </td>
    <td><table width="44%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><input name="in_sloan2" type="text" onChange="addIt()" value=0 size=4>
    var5</td>
    </tr>
    <tr>
    <td><input name="in_parent_cont2" type="text" onChange="addIt()" value=0 size=4>
    var6</td>
    </tr>
    <tr>
    <td><input name="in_pt_job2" type="text" onChange="addIt()" value=0 size=4>
    var7</td>
    </tr>
    <tr>
    <td><input name="in_other2" type="text" onChange="addIt()" value=0 size=4>
    var8</td>
    </tr>
    <tr>
    <td> </td>
    </tr>
    <tr>
    <td><input type="text" name="output2" size="6">
    <strong>tot2</strong></td>
    </tr>
    </table></td>
    <td><input name="finalout" type="text" id="finalout" size="6">
    <strong>final tot </strong></td>
    </tr>
    </table>
    </FORM>

    </body>
    </html>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    as far as I can see, there is nothing wrong with the HTML or javascript here... The input values should go to that server-side application you said you have it... Of course, if you specify that in the form's tag....

    <form name="adder" method="post" action="URL_here">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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