Results 1 to 3 of 3
-
5th Feb 2011, 01:44 AM #1OPMemberWebsite's:
ZVER.TV Studio9Resources.comJavascruot 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
-
5th Feb 2011, 11:14 AM #2Member
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' ) )
(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.");
}
-
5th Feb 2011, 12:37 PM #3OPMemberWebsite's:
ZVER.TV Studio9Resources.comyeah thanks edited a bit up and it worked
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Filehost not counted properly
By Chris2k in forum Web Development AreaReplies: 0Last Post: 10th Apr 2012, 01:06 AM -
Help! My theme Isn't loading properly
By sinefix in forum WordpressReplies: 8Last Post: 27th Mar 2012, 10:33 AM -
[Other] sBorg server 1gbps,Europe,Torrents WORKING properly
By maulin2good in forum ArchiveReplies: 12Last Post: 19th May 2011, 06:56 PM -
Cannot Access KWWH properly
By janu123 in forum Feedback and SuggestionsReplies: 6Last Post: 28th Feb 2011, 09:02 AM -
Help - Not showing properly on Opera.
By CyberJ37 in forum Web Development AreaReplies: 18Last Post: 1st Jul 2010, 02:59 PM
themaCreator - create posts from...
Version 3.47 released. Open older version (or...