Price calculation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • printline
    New Member
    • Jul 2006
    • 89

    Price calculation

    I am need of a simple price calculation script that will give users a price on a Printed Circuit Board.

    Here is an example:

    I have a panel that is 18 dm². A customers wants 1 PCB that is 100mm X 200mm (=2 dm²). The price is 20 € pr dm² which will give the customer a price that says 40 €.

    The situation can also be that he wants more than 1 PCB.

    What i then need in my script is for it to calculate the PCB's width and length (100mm X 200mm) and convert it to dm² and then multiple that number with the quantity of boards and then the price per dm².

    Like so: 100mm x 200mm = (2dm²) x 4 PCB's x 20€ = 160€

    Additionally there could be some static values that should be added to the price. For example if the customer wants the board to be electrical tested he should pay 10 € extra, which would then be added to the final cost price.

    Hope someone can get me started with this script.

    I would be very gratefull to anyone who could help me.

    Best regards
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    What have you managed so far? First get your form ready so you can code the script to take the variables and output the calculation.

    Comment

    • printline
      New Member
      • Jul 2006
      • 89

      #3
      Here is what i have so far:

      [HTML]<form name="Onlinepri ceform" method="post" action="onlinep rice2.php">
      <table>
      <tr>
      <td>Part Name</td>
      <td>
      <input type="text" name="part_name " id="part_name" />
      </td>
      </tr>
      <tr>
      <td>Quantity</td>
      <td>
      <input type="text" name="quantity" id="quantity" size="10" />
      </td>
      </tr>
      <tr>
      <td>Layers</td>
      <td><select name="layers" id="layers" size="1">
      <option selected="selec ted" value="2">2</option>
      <option value="4">4</option>
      <option value="6">6</option>
      </select>
      </td>
      </tr>
      <tr>
      <td>Board size (width)</td>
      <td>
      <input name="Board_siz e_x" type="text" id="Board_size_ x" size="10">
      </td>
      </tr>
      <tr>
      <td>Board size (lenght)</td>
      <td>
      <input name="Board_siz e_y" type="text" id="Board_size_ y" size="10">
      </td>
      </tr>
      <tr>
      <td>Board thickness</td>
      <td>
      <input type="text" name="Board_thi ckness" size="10" id="Board_thick ness" />
      </td>
      </tr>
      <tr>
      <td>Delivery (days)</td>
      <td>
      <select name="Delivery" id="Delivery">
      <option selected="selec ted" value="4 days">4 days</option>
      <option value="5 days">5 days</option>
      <option value="6 days">6 days</option>
      </select>
      </td>
      </tr>
      <tr>
      <td>Electrica l Test</td>
      <td>No<input name="e-test" type="radio" value="No" />
      <br />
      Yes<input name="e-test" type="radio" value="Yes" />
      </td>
      </tr>
      <tr>
      <td><input type="image" src="images/opnext.gif" name="send" style="border-style:none"></td>
      </tr>
      </table>
      </form>[/HTML]

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Where are you going to display the price? What's going to trigger the price calculations? A button click or on each key press, or onchange or selection?

        To get an element value, use document.getEle mentById(id).va lue. To convert it into an integer, use parseInt(). Try and see what you can come up with.

        Comment

        Working...