Solved

problem with a simple switch code on java script

Posted on 2014-03-25
7
252 Views
Last Modified: 2014-03-25
hi
i write this code for learning purposes but  its not working please tell me what it the problem with this code:
Var grade = "premium";
switch ( grade ) {
	case "premium":
		alert ("You select premium");
		break;
	case "Regular":
		alert ("you select Regular");
		break;
	case "Diesel":
		alert ("you select Diesel");
		break;
	default:
		alert ("you don't select nothing");
}
		

Open in new window


thanks
0
Comment
Question by:bill201
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 167 total points
ID: 39952958
Javascript is case-sensitive. The keyword is var--lowercase "v"--not Var.
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 167 total points
ID: 39952960
Var is lowercase :
var grade = "premium"
test page : http://jsfiddle.net/TVkwJ/
0
 
LVL 9

Assisted Solution

by:BlueYonder
BlueYonder earned 166 total points
ID: 39952965
The javascript looks fine.  Add this as a function using the example on http://www.w3schools.com/js/js_functions.asp.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39952978
All due respect, I'm not sure why BlueYonder's comment is considered to be a solution, since the Javascript was not fine...
0
 

Author Comment

by:bill201
ID: 39953003
You're right.  but still he tried    to help and he brought a similar and excellent  code so  for a thanks I gave him points.
0
 

Author Comment

by:bill201
ID: 39953017
Dear Kaufmed You deserved more points but 500 it's the best I can give and I wanted to please everyone.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39953028
I'm good on the points. If his post helped you, then that's what matters  = )

I didn't look at his link, so I have no idea if it was beneficial.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 39
Javascript create file issue 4 49
Google Sheets Script 21 58
Angular.js example vocabulary extensions 5 35
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now