Dodaj do ulubionych

JAVA SCRIPT

28.12.08, 18:15
PROGRAM = DOSTAWA PICCY ZA DARMO,1 FUNTA,WCALE.
CUS ZLE BO POD KONIEC POJAWIAJA SIE 2 KOMUNIKATY,chcialem tylko jeden ze powyzej 12 mil nie da rady a pojawia sie i drugi.


DLACZEGO?

dzieki jesli ktos wpadnie dlaczego..........


<html>
<body>
<script>
// A delivery charge program for the Fenland Pizza Company
var distance;
var extraDistance; // A variable you will need to use
distance = window.prompt('Please enter the distance in miles', '');
distance = parseFloat(distance);
if (distance>="3") {
document.write("Delivery for 1 Pound!")
}
if (distance<"3") {
document.write("Delivery for free!")
}
if (distance>"12") {
document.write("SORRY, but 12 miles is the maximum distance that Fenland will deliver!")
}
</script>
</body>
</html>
Obserwuj wątek
    • mmiga Re: JAVA SCRIPT 29.12.08, 10:21
      if (distance>"12")
      {
      document.write("SORRY, but 12 miles is the maximum distance that Fenland will deliver!")
      }
      else
      {
      if (distance>="3") {
      document.write("Delivery for 1 Pound!")
      }
      if (distance<"3") {
      document.write("Delivery for free!")
      }

      }

      Coś w ten deseń.
      Poza tym nie powinieneś porównywać do stringów "3", tylko do liczb - 3.

      pozdrawiaMM
    • f_a_k_y Re: JAVA SCRIPT 29.12.08, 14:40
      Dzieki.

      Przepisalem to z zadania.Poczatek jest;

      <HTML>
      <HEAD>
      <TITLE>TMA 02 Q4(iii)</TITLE>
      <SCRIPT LANGUAGE = "JavaScript">
      // A delivery charge program for the Fenland Pizza Company
      var distance;
      var extraDistance; // A variable you will need to use
      distance = window.prompt('Please enter the distance in miles', '');
      distance = parseFloat(distance);
      // Insert your code here
      </SCRIPT>
      </HEAD>
      <BODY>
      </BODY>
      </HTML>

      Musze wpisac reszte.Wyszlo mi tak jak w pierwszym poscie,ale cos jest zle,musze doczytac jeszcze.

Nie masz jeszcze konta? Zarejestruj się


Nakarm Pajacyka