Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help trying to make a times to money calculator

    Hi all this is my first post here. Found this place by google

    Well basically i have coded a java script well edited from here i think.

    This is the page at the moment
    http://rowleysdiscos.co.uk/instant.php

    but I'm trying to edit to i have drop down boxes with

    Start

    6:00
    6:30
    7:00
    7:30
    8:00
    8:30

    End

    10:00
    10:30
    11:30
    12:00
    12:30
    01:00
    01:30

    Then the same for karaoke start and finish.

    But the hard part it getting the right

    So minium booking is 2 hours for 100 and then every hour after is 30 and 15 for 30 Min's karaoke is 5 an hour .

    i have look and tried everythink but just cart get it to work

    hope some one can help me

    Dave

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Despite the similar sounding names, Java is not the same as Javascript.
    Moving from the Java forum to the Javascript forum.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,733
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    As Fou-Lu has pointed out, Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Java is NOT short for JavaScript!

    This should move you forward:-


    Code:
    <form name = "myform">
    START TIME <select name = "startTime">
    <option value = "6" selected>6.00</option>
    <option value = "6.5">6.30</option>
    <option value = "7">7.00</option>
    <option value = "7.5">7.30</option>
    <option value = "8">8.00</option>
    <option value = "8.5">8.30</option>
    </select>
    
    END TIME <select name = "endTime">
    <option value = "10" selected>10.00</option>
    <option value = "10.5">10.30</option>
    <option value = "11">11.00</option>
    <option value = "11.5">11.30</option>
    <option value = "12">12.00</option>
    <option value = "12.5">12.30</option>
    <option value = "13">1.00</option>
    <option value = "13.5">1.30</option>
    </select>
    
    <br><br>
    
    <input type = "button" value = "Calculate Booking Cost" onclick = "calc()">
    <br><br>
    <span id = "result"></span>
    </form>
    
    
    <script type = "text/javascript">
    
    function calc() {
    var st = document.myform.startTime.value;
    var et = document.myform.endTime.value;
    var hours = et - st;
    alert ("Hours = " + hours);  // for testing
    if (hours <2) {hours = 2} // minimum 2 hours
    var extraHours = hours - 2;  // hours over 2
    var cost = 100 + (extraHours *30);  // at 30 per hour
    document.getElementById("result").innerHTML = "The cost of the booking is " + cost;
    }
    
    </script>
    Note how the value (not the text) of the start and end times is expressed as fractions of an hour (not minutes) and 01.00 is expressed 13 hours (not 1) to make the subtractions simple.

    Presumably you can do the same to work out the cost for karaoke.

    If a booking can be made for two hours, why is the last start time 8.30 rather than 11.30?

    Quizmaster: Which popular pizza, that shares its name with a famous work by Vivaldi, is normally divided into four sections, each containing different toppings??
    Contestant: Four cheeses.
    Last edited by Philip M; 08-21-2010 at 06:54 PM. Reason: typo

  • #4
    New to the CF scene
    Join Date
    Aug 2010
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks i will take a look at it now thanks ..


  •  

    Posting Permissions

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