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

Recommended Answers

All 3 Replies

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>
Member Avatar for diafol

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.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.