Results 1 to 5 of 5

Thread: Auto calculator

  1. #1
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Auto calculator

    Hi dont know if this can be done but i would like to have an auto calcculator for my ferret boarding we charg £2.50 a day so I would like to be able to add the date they arive and it would auto add £2.50 a day

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

    Default

    Fairly simple.

    Just multiply the number of days times 2.5, then display it.

    But we'd need to know the layout of your site to see how it would fit in.

    One thing you'll need to decide--
    Do you want it to be live on the page as the user enters the info or should this happen after the form has been submitted and page has loaded again?
    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

  3. #3
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Fairly simple.

    Just multiply the number of days times 2.5, then display it.

    But we'd need to know the layout of your site to see how it would fit in.

    One thing you'll need to decide--
    Do you want it to be live on the page as the user enters the info or should this happen after the form has been submitted and page has loaded again?
    ow thats great just a wight background and whatever is easer

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

    Default

    Code:
    <form name="calculator" action="?calc" onSubmit="this.cost.value = this.days.value*2.5;return false;">
    Number of days: <input name="days" type="text" value="<?php echo $_POST['days']; ?> "><br>
    Cost: <input type="text" name="cost" disabled value="<?php echo (@$_POST['days']*2.5); ?>"><br>
    <input type="submit" value="Calculate">
    </form>
    Something like that?


    Note that the PHP code acts as a backup if javascript isn't enabled on the users' computers. However, you must have PHP installed on your server and the page must end with a .php extension. If not, remove those value= attributes entirely, and know that the user must have javascript.
    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

  5. #5
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Code:
    <form name="calculator" action="?calc" onSubmit="this.cost.value = this.days.value*2.5;return false;">
    Number of days: <input name="days" type="text" value="<?php echo $_POST['days']; ?> "><br>
    Cost: <input type="text" name="cost" disabled value="<?php echo (@$_POST['days']*2.5); ?>"><br>
    <input type="submit" value="Calculate">
    </form>
    Something like that?


    Note that the PHP code acts as a backup if javascript isn't enabled on the users' computers. However, you must have PHP installed on your server and the page must end with a .php extension. If not, remove those value= attributes entirely, and know that the user must have javascript.
    That is exslent just what I wanted THANKS

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
  •