0

Hi,

I'm trying to create a form in php that helps calculate the distribution of payments to different places example..


Input box to say how much money I start off with (in this example it will be $200.00)


Input box for the total amount of money i want to add to category GAS... I will enter $100.00.

(After that I want the form to automatically process the left overs to my next category)

So for instance it will say

GAS = 100.00
Food = 100.00
Games = 0

But now i want to enter food to be 50.00 so it should automatically set Food to

Gas = 100.00
Food = 50.00
Games = 50.00

Total = 200.00 but it is distributed to its own category...


Hopefully i explained myself ok .....If you have questions please ask I will try to explain myself a little better. =D

Thanks

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by programmer12
0

Example Set up HERE

<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
  Starting Amount:
  <input type="text" name="textfield" id="textfield" />
 </form>
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><input type="text" name="textfield2" id="textfield2" /></td>
    <td><select name="select" id="select">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select>
    </td>
  </tr>
  <tr>
    <td><input type="text" name="textfield3" id="textfield3" /></td>
    <td><select name="select2" id="select2">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select></td>
  </tr>
  <tr>
    <td><input type="text" name="textfield4" id="textfield4" /></td>
    <td><select name="select3" id="select3">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select></td>
  </tr>
  <tr>
    <td><input type="text" name="textfield5" id="textfield5" /></td>
    <td><select name="select4" id="select4">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select></td>
  </tr>
  <tr>
    <td><input type="text" name="textfield6" id="textfield6" /></td>
    <td><select name="select5" id="select5">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select></td>
  </tr>
  <tr>
    <td><input type="text" name="textfield7" id="textfield7" /></td>
    <td><select name="select6" id="select6">
      <option value="Tithes" selected="selected">Tithes</option>
      <option value="Offering">Offering</option>
      <option value="Building Fund">Building Fund</option>
      <option value="Children Ministry">Children Ministry</option>
      <option value="Sunday School">Sunday School</option>
    </select></td>
  </tr>
  <tr>
    <td>SUBMIT</td>
    <td><input type="submit" name="button" id="button" value="Submit" /></td>
  </tr>
</table>
</body>
</html>
0

I don't really follow, but do you want to automatically distribute the remainder amongst the rest of the categories?

Your solution looks a little complicated.
Why not have a textbox for the total amount, then have a textbox for each category:

Tithes
Offering
Building Fund
Children Ministry
Sunday School

When you enter an amount in each box, the total is decremented by said amount. THis needs javascript as opposed to php. This isn't as simple as it looks as you have to ensure that the total share isn't greater than the donation and control the 'automatic sharing' if you wish to implement it.

You could use 'vanilla' js to do this or use a framework/library like jquery.

0

Nice thats exactly what Im looking to do... =D

I had a feeling it was going to be complicated =(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.