Javascript for Basic Programming

Today I will tell you guys about the javascript, soo.. what is javascript?

Javascript is one of many programming languages. it designed to run at client side and make our web pages alive, but nowadays there’s some javascript platform that can run at server side.

For more information about javascript in details, you can read Here.

So let’s begin with simple one,

First, create a new HTML file.

1

2.PNG

Then add event function on the button, like this
<button onclick=”count()”>Count!</button>

this onclick=” count()” will call count function on javascript that having some script to count the values of a triangle.

then next is type

<javascript>

function count(){

var b = document.getElementById(“b”).value;

var h =  document.getElementById(“h”).value;

var c = (b*h)/2;

console.log(c);

}

</javascript>

3

var b is a declaration from variable b that having the value from the element on our pages which having “b” to be it id.

console.log(c) is showing us the result from a formula on the console. There’s many ways to show the result like put it on alert, or just put it on another element at our web pages.

4

 

Also, there are many events on javascript, like onchange, onkeyup, onload etc. You can check event list here Javascript Event List

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s