Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Sunday, 6 April 2014

Popup Boxes in JavaScript


You can easily create Popup Boxes using JavaScript. Many developers and designers use them to interact with the user in three different ways:
  1. Alert Box

  2. Prompt Box

  3. Confirm Box


Monday, 12 August 2013

multiplication-of-numbers-using-javascript


This post will show a simple Code in JavaScript to Multiply Numbers in a particular range.

If you're a beginner, then first try to run your first program in JavaScript.

Write the following code in any text file like Notepad, Notepad++.
Now, save this file as "amitJavascript.html"


<html>
     <head><title>www.techterabyte.com javascript sample</title></head>
<script>
<!-- <script> tag is used to insert JavaScript into html document. -->

function multiplyNum(n) {
   var i, mul = 1; // variable declaration

   // loop to multiply numbers
   for (i = 5; i <= n; i++) {
      mul = mul*i;              
   }

   // this will print the multiplication of numbers from number 5
   alert("The multiplication of digits from 5 to "+ n + " is:\n\n\t " + mul);
}

</script>

<body>
<p style="font-weight: bold;">
www.techterabyte.com<br />
...Multiplication of numbers...</p>
<form name="MultiplicationForm">
   Multiplication of the digits from 5 to
   <input name="enterNum" type="text" />
   <input onclick="multiplyNum(MultiplicationForm.enterNum.value)" 
   type="button" value="CalculateResult" />
</form>
</body>
</html>


The above can be explained as:
  • <script> : this tag is used to insert JavaScript into html document
  •  !--      --> : these are used for comments


Now. open the above page(amitJavascript.html) under any Web Browser:

Output :(this will shown on the browser as web page)



Enter the maximum value and click on CalculateResult to generate multiplication result:



Through this you can multiply numbers in JavaScript by inserting <script> tag in HTML.




Tuesday, 21 August 2012

javascript

Run your first program in JavaScript !!



This post will describe you about running your first program in JavaScript.
Starting with this, a user must have some introductory knowledge:
  • It is a scripted weekly-typed, dynamic language.
  • Scripting language is a light-weight programming language.
  • Appeared in the year 1995 and was designed by Brendan Eich.
  • It is an implementation of ECMAScript language standard.
  • File-extension is .js
  • It is used in web pages, desktop apps, internet servers etc.

Write the following code in any text file like notepad, notepad++ etc,
 then save this file as .html or .htm extension: amitdiwanJS.html

_____________________________________________________________________
<html>
     <head><title>amtdw.blogspot.com</title></head>
<body>   

<!-- <script> tag is used to insert JavaScript into html document. -->
<script>
document.write("<p><u>first javascript program for beginners</u></p>");
document.write("<b>My Blog:amtdw.blogspot.com</b></p>") ;
</script>

</body>
</html>



____________________________________________________________________

The above can be explained as:
  •  for HTML tags refer my blog post for html i.e. 
  • <script> : this tag is used to insert JavaScript into html document.
  • document.write: this prints the text to the page.
  •  !--      --> : these are used for comments




Now. open the above page(amitdiwanJS.html) under any Web Browser:


Output :(this will shown on the browser as web page)





This way you can run your program in JavaScript by inserting <script> tag in HTML
Simple... :)



__________________________________________________________________________
Please comment and forward to others if you like this.
Other posts with video tutorial yet to come.....
"I am sure that blogs really help people around the world.
Let us follow this simple thinking of sharing knowledge . . ."