home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Archived / Internet / jvscript116beta / JvScript / !JvScript / Resources / Scripts / Games / 1 next >
Encoding:
Text File  |  1999-08-24  |  2.4 KB  |  73 lines

  1. #newformat
  2. _title:Love Test
  3. _author:JavaScript Source
  4. _description:Test 2 people's "Love Compatibility"
  5. _explanation:Please do not blame me (Geoff) for this script and it's consequences, it is nothing to do with me.
  6.  
  7. _insert-in:inhead
  8. <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
  9. <!-- Begin
  10. function calc() {
  11.  
  12. first = document.loveform.name1.value.toUpperCase();
  13. firstlength = document.loveform.name1.value.length;
  14. second = document.loveform.name2.value.toUpperCase();
  15. secondlength = document.loveform.name2.value.length;
  16. var LoveCount=0;
  17.  
  18. for (Count=0; Count < firstlength; Count++) {
  19. letter1=first.substring(Count,Count+1);
  20. if (letter1=='L') LoveCount+=2; 
  21. if (letter1=='O') LoveCount+=2; 
  22. if (letter1=='V') LoveCount+=2; 
  23. if (letter1=='E') LoveCount+=2; 
  24. if (letter1=='Y') LoveCount+=3; 
  25. if (letter1=='O') LoveCount+=1; 
  26. if (letter1=='U') LoveCount+=3;
  27. }
  28.  
  29. for (Count=0; Count < secondlength; Count++) {
  30. letter2=second.substring(Count,Count+1);
  31. if (letter2=='L') LoveCount+=2;
  32. if (letter2=='O') LoveCount+=2; 
  33. if (letter2=='V') LoveCount+=2; 
  34. if (letter2=='E') LoveCount+=2;
  35. if (letter2=='Y') LoveCount+=3;
  36. if (letter2=='O') LoveCount+=1;
  37. if (letter2=='U') LoveCount+=3; 
  38. }
  39.  
  40. amount=0;
  41. if (LoveCount> 0) amount=  5-((firstlength+secondlength)/2)
  42. if (LoveCount> 2) amount= 10-((firstlength+secondlength)/2)
  43. if (LoveCount> 4) amount= 20-((firstlength+secondlength)/2)
  44. if (LoveCount> 6) amount= 30-((firstlength+secondlength)/2)
  45. if (LoveCount> 8) amount= 40-((firstlength+secondlength)/2)
  46. if (LoveCount>10) amount= 50-((firstlength+secondlength)/2)
  47. if (LoveCount>12) amount= 60-((firstlength+secondlength)/2)
  48. if (LoveCount>14) amount= 70-((firstlength+secondlength)/2)
  49. if (LoveCount>16) amount= 80-((firstlength+secondlength)/2)
  50. if (LoveCount>18) amount= 90-((firstlength+secondlength)/2)
  51. if (LoveCount>20) amount=100-((firstlength+secondlength)/2)
  52. if (LoveCount>22) amount=110-((firstlength+secondlength)/2)
  53.  
  54. if (firstlength==0 || secondlength==0) amount= "Err";
  55. if (amount < 0) amount= 0;
  56. if (amount >99) amount=99;
  57.  
  58. document.loveform.output.value=amount+"%";
  59. }
  60. //  End -->
  61. </SCRIPT>
  62. _end-insert:
  63.  
  64. _insert-in:inbody
  65. <FORM NAME=loveform>
  66. <INPUT VALUE="Bill Clinton" NAME="name1" TYPE="text" SIZE="20"> + 
  67. <INPUT VALUE="Monica Lewinsky" NAME="name2" TYPE="text" SIZE="20"> = 
  68. <INPUT VALUE="" NAME="output" TYPE="text" SIZE="6">
  69. <BR>
  70. <BR>
  71. <INPUT VALUE="Calculate!" NAME="calculate" TYPE="button" VALUE="calculate" onClick="calc()">
  72. </FORM>
  73. _end-insert: