Page 1 of 1

create a form that calculates

Posted: Thu Nov 20, 2008 9:41 am
by dellvostro
Hello Fourm, very new to coding and need help with creating a simple form that can calculate numbers in fields.

Ideally, would like to find a script that I can modify easily. Just need about 20 or 30 lines two columns.

Description Amount

Option 1 5.00

Option 2 3.00

etc, etc, etc

Numbers need to be already visible, and total at bottom. Visitor has option of removing amount from various fields and the form should re calculate.

Thank you for any help.

Re: create a form that calculates

Posted: Thu Nov 20, 2008 4:33 pm
by infolock

Code: Select all

 
 
$total = $_POST['description_amount'] + $_POST['option_1'] + $_POST['option_2'];
 
echo $total;
 
 

If this isn't what you want, please be more descriptive. If you don't know how to create forms, post them to a php file, and then go from there, you'll want to google "PHP Post", "PHP Form POST", and such. This is your easiest way to learn.

Re: create a form that calculates

Posted: Fri Nov 21, 2008 8:59 am
by dellvostro
Thanks for your reply and help. Not sure if I was clear enough in original post. What id like to have is something like this below. Its very basic in layout. But I dont know how to turn this into a form that can be filled out by visitor and sent to my email.
Id also like the visitor to be able to uncheck any lines and have that subtract from total at bottom. Thanks for any insight to this.

Code: Select all

 
<style type="text/css">
<!--
.style19 {  font-family: "Times New Roman", Times, serif;
    font-weight: bold;
    font-size: 14px;
}
.style27 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
}
.style28 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; }
-->
</style>
<table width="675">
  <tr>
    <td class="style28"><label></label>
description line1: </td>
    <td class="style27"><form name="form2" method="post" action="">
      <label>
        <div align="center">
          <input name="radio" type="radio" id="descr1" value="descr1" checked>
        $2.0</div>
      </form>    </td>
  </tr>
  <tr>
    <td class="style28">description line2: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr2" value="descr2" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line3: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr3" value="descr3" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line4: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr4" value="descr4" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line5: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr5" value="descr5" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line6: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr6" value="descr6" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line7: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr7" value="descr7" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line8: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr8" value="descr8" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line9: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr9" value="descr9" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">description line10: </td>
    <td class="style27"><label>
      <div align="center">
        <input name="radio" type="radio" id="descr10" value="descr10" checked>
        $2.00</div>
    </label></td>
  </tr>
  <tr>
    <td class="style28">totals:</td>
    <td class="style27"><div align="center">$20.00</div></td>
  </tr>
</table>
<table style="border: 1px solid rgb(28, 28, 168);" cellpadding="3" cellspacing="3" height="255" width="100%">
  <tbody>
    <tr class="style19">
      <td height="28" class="style-bold style27">name:
        <input size="70" name="name" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="28" class="style-bold style27">Email:
      <input size="70" name="email" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="28" class="style-bold style27">Phone:
        <input size="50" name="phone" type="text" /></td>
    </tr>
    <tr>
      <td height="28" class="style-bold style27"><strong>Address:</strong>
          <input size="25" name="address" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="28" class="style-bold style27">City.:
        <input size="20" name="city" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="28" class="style-bold style27">State.:
        <input size="20" name="state" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="28" class="style-bold style27">Zip Code:
      <input size="20" name="zipcode" type="text" /></td>
    </tr>
    <tr class="style19">
      <td height="30" class="style27"><input name="submit" value="Submit" type="submit" /></td>
    </tr>
  </tbody>
</table>
<p class="style27">&nbsp;</p>
 

Re: create a form that calculates

Posted: Fri Nov 21, 2008 11:42 am
by mmj
If I understand you correctly you'd have to use JavaScript.

Add an onchange event to each element and put together a calculate function and you're get-to-go.

Re: create a form that calculates

Posted: Tue Nov 25, 2008 2:53 pm
by dellvostro
I dont know how to do that. I was hoping someone had something similar out there or an easily modifiable script or application. thanks.