Activity Stream
48,167 MEMBERS
6777 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member
    Website's:
    ZVER.TV Studio9Resources.com

    Default Javascruot Not Working Properly

    PHP Code: 
    //asks the user for a code letter then shows the manufacturing grade

    var userInput prompt ("Please enter your code letter here:""");

    if (
    userInput == "S" || "s")
    {
    document.write("Your manufacturing grade is Space Grade");
    }

    else if (
    userInput == "M" || "m")
    {
    document.write("Your manufacturing grade is Military Grade");
    }

    else if (
    userInput == "C" || "c")
    {
    document.write("Your manufacturing grade is Commercial Grade");
    }

    else (
    userInput == "T" || "t")
    {
    document.write("Your manufacturing grade is Toy Grade");



    P.S "The Result I get if I put anything is

    Your manufacturing grade is Space GradeYour manufacturing grade is Toy Grade.

    I get nothing else... any letter i put or not... to remove the second part of it like not showing hte last part for the letter "T" i just place

    else if on it and it works at the end, but again any letter number still gives me the first result only.
    Kr?niiK Reviewed by Kr?niiK on . Javascruot Not Working Properly //asks the user for a code letter then shows the manufacturing grade var userInput = prompt ("Please enter your code letter here:", ""); if (userInput == "S" || "s") { document.write("Your manufacturing grade is Space Grade"); } else if (userInput == "M" || "m") Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    lol first of all your conditional statements are wrong.
    To compare a variable with two values you have to do it like:-
    PHP Code: 
    ( (userInput == 's' ) || (userInput == 'S' ) ) 
    The second problem in your code is that u are putting a conditional statement with `else` (maybe u forgot what elseif is for )

    And why dont u just convert userInput to lowercase and then compare
    So your code should look like:-

    PHP Code: 
    var userInput prompt("Please enter your code letter here:""").toLowerCase();

    if (
    userInput == "s")
    {
    document.write("Your manufacturing grade is Space Grade");
    }

    else if (
    userInput == "m")
    {
    document.write("Your manufacturing grade is Military Grade");
    }

    else if (
    userInput == "c")
    {
    document.write("Your manufacturing grade is Commercial Grade");
    }

    else if (
    userInput == "t")
    {
    document.write("Your manufacturing grade is Toy Grade");
    }

    else 
    {
    document.write("You didnt enter a code letter.");


  4.     
    #3
    Member
    Website's:
    ZVER.TV Studio9Resources.com
    yeah thanks edited a bit up and it worked

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Filehost not counted properly
    By Chris2k in forum Web Development Area
    Replies: 0
    Last Post: 10th Apr 2012, 01:06 AM
  2. Help! My theme Isn't loading properly
    By sinefix in forum Wordpress
    Replies: 8
    Last Post: 27th Mar 2012, 10:33 AM
  3. [Other] sBorg server 1gbps,Europe,Torrents WORKING properly
    By maulin2good in forum Archive
    Replies: 12
    Last Post: 19th May 2011, 06:56 PM
  4. Cannot Access KWWH properly
    By janu123 in forum Feedback and Suggestions
    Replies: 6
    Last Post: 28th Feb 2011, 09:02 AM
  5. Help - Not showing properly on Opera.
    By CyberJ37 in forum Web Development Area
    Replies: 18
    Last Post: 1st Jul 2010, 02:59 PM

Tags for this Thread

BE SOCIAL