javascript where to declare variables

javascript where to declare variables

javascript where to declare variables

View Answers

April 4, 2012 at 4:36 PM

Javascript variable always be declared inside script tag.

<script>
var x=15;
var y=16;
var sum=x+y;
document.writeln("Sum ="+sum);
</script>

For more information, visit the following link:

Declare variables in Javascript


April 4, 2012 at 4:38 PM

JavaScript where to declare variables

To declare a variable in JavaScript me must follow the syntax. As given below

Syntax

<script language="javascript">

//  declare variable or do your calculation

  </script>"

See an example given below that show how to declare a variable in JavaScript.

<Script Language="JavaScript">

var name, age;

name = Java;
age = 7;
document.write(name);
document.write("<br>");
document.write(age);
</Script>

In the above example name and age are two variable and further we have assigned some value to it. Always remember that the variable name must be written in small letters. document.write (); is used to print the value of variable.









Related Tutorials/Questions & Answers:
javascript where to declare variables
variables in Javascript   JavaScript where to declare variables To declare...javascript where to declare variables  javascript where to declare variables   Javascript variable always be declared inside script tag
JavaScript Variables
JavaScript Variables: Variables are like containers, which contains a value. In JavaScript variables dependent on the value, not on the datatype that means variables are of  dynamic typing. Variable names are case-sensitive
Advertisements
What is JavaScript Variables ?
What is JavaScript Variables ?  Hi, My question is that What is Variable in JavaScript Programming Language. How to declare variables in JavaScript Program. Thanks, (adsbygoogle = window.adsbygoogle || []).push
JavaScript where to place in HTML
JavaScript where to place in HTML   Where to place JavaScript code into HTML Code?   Placing JavaScript code into HTML Code In HTML, JavaScript can be declared anywhere either in <Head>â?¦ or <Body>â?¦ Tag
Where can I learn JavaScript
Where can I learn JavaScript  Hi, I have HTML knowledge and now want to learn JavaScript. Which is the best tutorials to learn JavaScript? Where can I learn JavaScript? Thanks   Hi, JavaScript is programming
how to get javascript variables into jsp - JSP-Servlet
how to get javascript variables into jsp  How to pass variables from java script into jsp page  Hi Friend, Try it: 1)pass.jsp: var msg="Hello World" window.location.href="show.jsp?value=" + msg
Variables
Variables  What are the difference between Static variables, instance variables and local variables
PHP Variables in JavaScript
PHP Variables in JavaScript JavaScript and PHP both are scripting language... on the internet.ADS_TO_REPLACE_1 Let's see how can you use PHP variables in JavaScript..., in this way you can use PHP variables in JavaScript
Variables in Java
; Declaring variables Before using variables you must declare the variables  name... Variables in Java       In this section, you will learn about Java variables
Declare construct
Declare construct  hii, Define about declare construct?   hello,ADS_TO_REPLACE_1 Declare construct allows you to define execution... perform. These declare construct can be set in such a manner that all the code
how do i update my database with the help of update syntax in html <text/javascript>? How to write 'where' statement in this?
how do i update my database with the help of update syntax in html ? How to write 'where' statement in this?  var sqlmek="update into Student_info set(ID,s_name,l_name,address,pincode,mobile_no,mail_id)values ("; sqlmek
How to Print Array in JavaScript
How to Print Array in JavaScript In this section you will learn about Array in JavaScript. Array are important part of all programming languages. Array in JavaScript is a variable that can hold more than one value. Array is a collection
PHP Variable variables
PHP Variables variable: Variables variable is a new kind of technique of using variables, in this technique we need to use more than one variable and we can use those variables dynamically. As in the following examples we can see
Declare the Navigation Rules
Declare the Navigation Rules  How to declare the Navigation Rules for JSF
Variables in Java
and defining variables Before using variables you must declare the variables  name... Variables       Data... declare a variable we need to specify the  type of value it will hold along
Variables in Java
Variable in Java In this section you will learn about variables in java. First we should know, what is variable? variable is a location in the memory where... can also declare more than one variable at at time and you can also initialize
JavaScript
JavaScript  clone JavaScript
getting variables
getting variables   how to get variables from servlet program to webservice program
How to declare NSMatrix
How to declare NSMatrix  How to declare NSMatrix in XCode can anyone explain it with example
Declare Cursors in SQL
Declare Cursors in SQL       Declare Cursors in SQL is used to define cursor and its... a example from 'Declare Cursors in SQL'. To grasp the example, we create a table
How to Declare Abstract Class in PHP ?
How to Declare Abstract Class in PHP ?  hi, I am a PHP Beginners. As i am trying to make an application where i trying to declare the abstract class of PHP. Please any one explain me how to declare abstract class in PHP program
ModuleNotFoundError: No module named 'declare'
ModuleNotFoundError: No module named 'declare'  Hi, My Python... 'declare' How to remove the ModuleNotFoundError: No module named 'declare... to install padas library. You can install declare python with following command
JavaScript Variables and Data types
 JavaScript Variables and Data types... will learn the basics of JavaScript Variables and Data types. JavaScript Variables... and Initializing the Variables var num   // declare variable, has null value num = 20
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Environment variables
Environment variables  How to set Environment Variables in JAVA 6 n Tomcat 6 CLASSPATH, JAVA_HOME, PATH, & CATALINA variables plzzz plzz help me
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
JavaScript clearTimeOut method
JavaScript clearTimeOut method       JavaScript's HTML DOM window object method clearTimeOut() method is used to stop or clear the time out variables value
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
How to declare array in Java?
How to declare array in Java?  Hi, How to declare array in Java? Thanks   Hi, Following is a code of declaration of String array: String[] javaTechnologies = new String[]{"Java", "JSP", "Servlet", "JPA"}; Example
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
Declare Reference variable
Declare Reference variable   class A { int a; //instance... is shared. I just want to ask if we declare Reference variable above then what does...?? (Generally we used to declare reference variable in main method at the time
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ââ?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code:ADS_TO_REPLACE_1 form.jsp: <html> <script>... Javascript value In JSP"> <% String st=request.getParameter("msg"); if(st
Javascript
this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function..." method="post" onsubmit="javascript:return validate();"> Phone Number:<
Javascript
Javascript  Dear Sir, Thank You a lot for your continuos support.Again i am in need of your help. What is the javascript code to disable a link,once... javascript or css Please help me.Urgent Regards Debasis   Hello Friend
Javascript
Javascript  <html> <head> <script type="text/javascript"> function validateForm() { var sname=document.getElementById('spocname'); var scontact=document.getElementById('spoccontact'); if(sname.value.length
javascript
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions() { document.getElementById("text").value=" "; var Questions = new Array(20
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
javascript

Ads