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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript function problem.

    Hi,
    I'm trying to make a website that is going to be used as a horoscope teller.

    I have written the code below but when opening it in Internet Explorer (Service pack 2 installed) it comes up with an error message that says that there is something wrong with the code that will make the computer run slowly. Do I want to abort the script!

    Does anyone know why this may be happening??

    Any help would be appreciated greatly!!

    Thanks again

    Here is the script : -

    <script type = "text/javascript">

    var firstName, secondName, birthDate, birthMonth, findElement;

    function findHoroscope () {
    retrieveInput ();
    checkDate ();
    checkMonth ();
    findStarsign ();
    findElement ();
    window.alert (firstName + " , your starsign is " + findStarsign + "and your element is " + findElement)
    return;
    }

    function retrieveInput () {
    firstName = document.starsign.first.value;
    secondName = document.starsign.second.value;
    birthDate = document.starsign.date.value;
    birthMonth = document.starsign.month.value;
    return; }

    function checkDate () {
    var birthDate = ((0<parseInt (document.starsign.date.value) && parseInt (document.starsign.date.value) <=31) ? true
    :false);
    if (birthDate == false) window.alert ("Problem with the date");
    return birthDate; }

    function checkMonth () {
    var birthMonth = (document.starsign.month.value == "January" ? true
    :document.starsign.month.value == "February" ? true
    :document.starsign.month.value == "March" ? true
    :document.starsign.month.value == "April" ? true
    :document.starsign.month.value == "May" ? true
    :document.starsign.month.value == "June" ? true
    :document.starsign.month.value == "July" ? true
    :document.starsign.month.value == "August" ? true
    :document.starsign.month.value == "September" ? true
    :document.starsign.month.value == "October" ? true
    :document.starsign.month.value == "November" ? true
    :document.starsign.month.value == "December" ? true
    :false);

    if (birthMonth == false) window.alert ("Problem with the month");
    return birthMonth; }

    function findStarsign () {
    while ((checkDate == true) && (checkMonth == true));
    var findStarsign = (
    ((birthDate == 21-31) && (birthMonth == "March"))?
    "Aries" :
    ((birthDate == 1-19) && (birthMonth == "April"))?
    "Aries" :
    ((birthDate == 20-30) && (birthMonth == "April"))?
    "Taurus" :
    ((birthDate == 1-20) && (birthMonth == "May"))?
    "Taurus" :
    ((birthDate == 21-31) && (birthMonth == "May"))?
    "Gemini" :
    ((birthDate == 1-21) && (birthMonth == "June"))?
    "Gemini" :
    ((birthDate == 22-30) && (birthMonth == "June"))?
    "Cancer" :
    ((birthDate == 1-22) && (birthMonth == "July"))?
    "Cancer":
    ((birthDate == 23-31) && (birthMonth == "July"))?
    "Leo" :
    ((birthDate == 1-22) && (birthMonth == "August"))?
    "Leo" :
    ((birthDate == 23-31) && (birthMonth == "August"))?
    "Virgo" :
    ((birthDate == 1-22) && (birthMonth == "September"))?
    "Virgo" :
    ((birthDate == 23-30) && (birthMonth == "September"))?
    "Libra" :
    ((birthDate == 1-22) && (birthMonth == "October"))?
    "Libra" :
    ((birthDate == 23-31) && (birthMonth == "October"))?
    "Scorpio" :
    ((birthDate == 1-21) && (birthMonth == "November"))?
    "Scorpio" :
    ((birthDate == 22-30) && (birthMonth == "November"))?
    "Sagittarius" :
    ((birthDate == 1-21) && (birthMonth == "December"))?
    "Sagittarius" :
    ((birthDate == 22-31) && (birthMonth == "December"))?
    "Capricorn" :
    ((birthDate == 1-19) && (birthMonth == "January"))?
    "Capricorn" :
    ((birthDate == 20-31) && (birthMonth == "January"))?
    "Aquarius" :
    ((birthDate == 1-18) && (birthMonth == "February"))?
    "Aquarius" :
    ((birthDate == 19-29) && (birthMonth == "February"))?
    "Pisces" :
    ((birthDate == 1-20) && (birthMonth == "March"))?
    "Pisces":
    "Unable to find starsign - please check that your birth date and month is correct");

    return findStarsign; }

    function findElement () {

    var findElement = ("Air" || "Earth" || "Water" || "Fire");

    if (findElement == "Air")
    while (findStarsign = ("Gemini" || "Libra" || "Aquarius"));
    {return ("Air");} {
    if (findElement == "Earth")
    while (findStarsign = ("Taurus" || "Virgo" || "Capricorn"));
    {return ("Earth");} {
    if (findElement == "Water")
    while (findStarsign = ("Cancer" || "Scorpio" || "Pisces"));
    {return ("Water");} {
    if (findElement == "Fire")
    while (findStarsign = ("Aries" || "Leo" || "Sagittarius"));
    {return ("Fire");}
    } } } }

    </script>

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by asharm27
    Does anyone know why this may be happening??
    Well, since it appears to be one gigantic, compounded, ternary expression, that might be the problem...
    Last edited by codegoboom; 03-19-2005 at 01:36 AM. Reason: !unary... :o
    *this message will self destruct in n-seconds*

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    There are in fact five basic elements - earth, air, fire, water and bull****.


  •  

    Posting Permissions

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