home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Internet / jvscript116beta / JvScript / !JvScript / Resources / Scripts / XCalcs / 4 < prev    next >
Encoding:
Text File  |  1999-08-24  |  1.7 KB  |  70 lines

  1. #newformat
  2. _title:Phone Bill
  3. _description:Click start when the call begins and see the total charge at any time.
  4.  
  5. _insert-in: head
  6. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  7. <!-- Begin
  8. function decimal(num) {
  9. string = "" + num;
  10. if (string.indexOf('.') == -1)
  11. return string + '.00';
  12. seperation = string.length - string.indexOf('.');
  13. if (seperation > 3)
  14. return string.substring(0,string.length-seperation+3);
  15. else if (seperation == 2)
  16. return string + '0';
  17. return string;
  18. }
  19. i=0;
  20. x=0;
  21. countit="yes";
  22. function count() {
  23. if (i == 60) { i=0; x=(x + 1)}
  24. document.money.minutes.value = x;
  25. i++;
  26. document.money.seconds.value = i;
  27. document.money.owed.value = "$" + 
  28. decimal((x * document.money.permin.value) + 
  29. eval(document.money.initial.value));
  30. if (countit != "no") {
  31. setTimeout('count()',1000);
  32.    }
  33. }
  34. function stop() {
  35. countit="no";
  36. }
  37. // End -->
  38. </SCRIPT>
  39. _end-insert:
  40.  
  41. _insert-in:inbody
  42. <form name=money>
  43. <table border=1 bgcolor="#f5f5f5">
  44. <tr>
  45. <td>Initial amount added to every call:</td>
  46. <td>
  47. <input name=initial type=text value="1.25" size=20 onChange="document.money.owed.value = decimal(document.money.initial.value)"></td>
  48. </tr>
  49. <tr>
  50. <td>Amount per minute:</td>
  51. <td><input name=permin type=text value=".10" size=20></td>
  52. </tr>
  53. <tr>
  54. <td>Number of minutes passed:</td>
  55. <td><input name=minutes type=text size=20></td>
  56. </tr>
  57. <tr>
  58. <td>Seconds in current minute:</td>
  59. <td><input name=seconds type=text size=20></td>
  60. </tr>
  61. <tr>
  62. <td>Amount of phone call:</td>
  63. <td><input name=owed type=text size=20 value="$0.00"></td>
  64. </tr>
  65. <tr>
  66. <td colspan=2 align=center><input type=button value=" Start " onClick="countit='yes'; count()"><input type=button value=" Stop " onClick="stop()"></td>
  67. </tr>
  68. </table>
  69. </form>
  70. _end-insert: