I need a Dynamic Order Form?

Discussion in 'Programming' started by Ash, Mar 21, 2007.

  1. #1
    Hi,
    Does anyone have any idea how to do a dynamic order form? Let me explain.

    Someone goes to my website and wants me to create a website for them. I have always had trouble charging them the right amount so i wish there was a way the customer could find out how much it will cost for them without having to contact us for a quote first. Therefore i thought some kind of form might be a good idea.

    They select what they want. For example, they tick boxes saying:

    Website Design - £75
    News Page - £25
    CMS Integration - £50
    1 Page - £25
    2 Pages - £50
    3 Pages - £75
    6 Pages - £150

    Etc.

    Then on each thing they select the form (or something) adds it up, and at the end, brings them with a total price of what it would cost.

    Anyone know how to do this?

    Thanks.
     
    Ash, Mar 21, 2007 IP
  2. Robert Plank

    Robert Plank Peon

    Messages:
    55
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    How's this?

    <form action="#" onsubmit="return false;">
    
    <p>
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="75.2" /> Website Design - &pound;75</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="25.69" /> News Page - &pound;25</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="50" /> CMS Integration - &pound;50</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="25" /> 1 Page - &pound;25</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="50" /> 2 Pages - &pound;50</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="75" /> 3 Pages - &pound;75</label><br />
       <label><input type="checkbox" name="item" onclick="update(this.form)" value="150" /> 6 Pages - &pound;150</label><br />
    </p>
    
    <p>
       Your Total: &pound; <input type="text" name="total" id="total" size="10" value="0.00">
    </p>
    </form>
    
    <script type="text/javascript">
    <!--
    
    function update(formObj) {
       var total = 0;
    
       for (var i=0; i<formObj.item.length; i++) {
          var myItem = formObj.item[i];
          if (myItem.checked) {
             total += parseFloat(myItem.value);
          }
       }
    
       var cents = Math.round((total*100) % 100);
       var dollars = Math.floor(total);
    
       var moneyValue = dollars + "." + cents;
       if (cents == 0) { moneyValue += "0"; }
    
       formObj.total.value = moneyValue;
    }
    
    // -->
    </script>
    Code (markup):
     
    Robert Plank, Mar 22, 2007 IP