Results 1 to 3 of 3

Thread: 3 item calculator

  1. #1
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 3 item calculator

    I am trying to figure out a way to build a 3 item calculator. The way I see this set up is as follows:

    Checkbox1 Checkbox2 Checkbox3

    Total Displayed Here


    I am trying to make something so when a check box is selected the price will display in an input box. If 2 items are selected, it will display the combined price and if 3 are selected it will do the same.

    I know very little php, but was told it could be done.

    Any help or ideas would be great!

    Here is a link to a quick html page I put together.

    http://www.settlementonehosting.com/...alculator.html

    Thanks again!!

  2. #2
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    hey..

    its difinatly possable.. but i think javascript would be a better option for u.. or a combination of both php and js..

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP would require the page to be reloaded or the form sent. With javascript, it could respond immediately to the checkboxes.

    for each checkbox... here's something you could try...

    <input type="checkbox" value="3.88" onChange="if (this.checked == 1) { pricefield.value = pricefield.value+this.value; } else { pricefield.value = pricefield.value-this.value; }">

    I believe that would suit your needs.

    This would, by the way, require that the "results" field be called:
    <input type="text" id="pricefield" name="pricefield">

    Also, to avoid weird errors, it would require that each checkbox load unchecked, and the value of the pricefield start at 0.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •