Hi Guys, I am Sravan, and I want to share some of my knowledge in javascript through this blog. Javascript is really a very easy programming language to learn and is used everywhere, right from web to games.
Today, I am going to share a basic javscript program which converts the celsius to fahrenheit. Before learning javascript, you should have a basic knowledge about HTML, because this comes under web development.
So, here is the programming video of the basic temperature converter which converts Celsius to Fahrenheit. In this video, you will be learning:
Description of the video:
<script> and </script> is the place where javascript program is done. To get an input value from the input text box, firstly, the input text box should have an 'id'. In this video 'celsius' is the id of the input text field.
In order to get the id of the text field, 'document.getElementById('celsius')' is used. In the above video we have assigned the input text field id to a variable called 'cel'. Thus to get the value from input we use 'cel.value'. Similarly, we do the same for the button. But in Button we have another attribute called 'onClick'.
We have created a function called c2f, in which the logic of temperature converter is. To create a function in javascript, we use
function functionname(){
}
(or)
var functionname=function(){
}
And to convert temperature on clicking the button, the onClick attribute calls the function. Thus, c2f() is set to onClick. The 'alert' is used to create dialog box with 'OK' option. alert can be used as below
alert('string')
alert('Hi I am learning Javascript')
In the above video, we have used alert(cel+' celsius is equal to '+far), where cel and far are variables and is concatenated to a string.That is all the basics you need to know about javascript.
Today, I am going to share a basic javscript program which converts the celsius to fahrenheit. Before learning javascript, you should have a basic knowledge about HTML, because this comes under web development.
So, here is the programming video of the basic temperature converter which converts Celsius to Fahrenheit. In this video, you will be learning:
- To get an input from the user
- To create a function
- onClick event of the Button
Description of the video:
<script> and </script> is the place where javascript program is done. To get an input value from the input text box, firstly, the input text box should have an 'id'. In this video 'celsius' is the id of the input text field.
In order to get the id of the text field, 'document.getElementById('celsius')' is used. In the above video we have assigned the input text field id to a variable called 'cel'. Thus to get the value from input we use 'cel.value'. Similarly, we do the same for the button. But in Button we have another attribute called 'onClick'.
We have created a function called c2f, in which the logic of temperature converter is. To create a function in javascript, we use
function functionname(){
}
(or)
var functionname=function(){
}
And to convert temperature on clicking the button, the onClick attribute calls the function. Thus, c2f() is set to onClick. The 'alert' is used to create dialog box with 'OK' option. alert can be used as below
alert('string')
alert('Hi I am learning Javascript')
In the above video, we have used alert(cel+' celsius is equal to '+far), where cel and far are variables and is concatenated to a string.That is all the basics you need to know about javascript.
Hope you like it. The next part of the Temperature converter contains radio buttons and it will follow in the next post....Till then
Cheers
Sravan
No comments:
Post a Comment