Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Wednesday, July 10, 2013

How To Show Different Greetings at Different Times During The Day Using Javascript

0 comments
To show different greetings for different times of day we use if else loop.here is a example which help you to sow different greetings of the day.

<HTML><HEAD><TITLE>Examples of using a Date object and the if and if else statements.</TITLE></HEAD><BODY><PRE> This script provides examples of using the Date object to obtain the hour of the day. The hour is used to print different messages at different times during the day. 
<SCRIPT Language="JavaScript"> 
now = new Date()                 //create a Date object named: now
hour = now.getHours()         //hours range from 0 to 23.
                                           //0 is midnight to before 1 AM.  
noon = 12                          //Afternoon begins at noon.
evening = 18                     //Evening begins at 6 PM.
if (hour < noon)
document.writeln("Good Morning.")
else if (hour < evening)
document.writeln("Good Afternoon.")
else
document.writeln("Good Evening.")
</SCRIPT>
</PRE>
</BODY>
</HTML>

OUTPUT :This script provides examples of using the Date object to obtain the hour of the day. The hour is used to print different messages at different times during the day.
Good Evening.
NOTE: Here the msg is shown good evening because hour>afternoon i.e. the third loop is used.
Read more...
Monday, July 8, 2013

How To Show Time and Date Using Javascript

0 comments
In this article,We can show time and date using javascript.
now = new Date() 
JavaScript provides a Date object that makes dealing with dates and times relatively easy.In this line a new Date object named now is created using the new object creation operator. This is a little different from how objects have been used in the examples up until now. String objects can be created by assigning literal text to a variable and then treating that variable as though it has properties and methods. The document and Math objects are created by the browser and interpreter environments and are ready to use by any script executed by them. The Date object however is designed to provide a way to create Date objects for a given date or time. The sample line creates a Date object named now that contains the date and time when the now Date was created. Like the String, document, and Math objects the Date object provides numerous useful methods for working with dates and times. 
hour = now.getHours() 
Just one of the useful methods provided by the Date object is the getHours() method. getHours()returns the hour of the time stored in the now variable. The hour is between 0 (midnight) and 23 (11 PM). If the time was between noon and less than 1 PM (13 hours) getHours() will return 12.

Here is a example,

<HTML>
 <HEAD>
<TITLE>How To Show Time and Date Using Javascript Simple Eample</TITLE>
 </HEAD>
 <BODY>
 <PRE>This Script help you to show time and date.
 <SCRIPT Language="JavaScript">

 now = new Date()                     //create a Date object named: now
 hour = now.getHours()            //hours range from 0 to 23.
                                               //0 is midnight to before 1 AM.
  document.write(now)
 </SCRIPT>
 </PRE>
 </BODY>
 </HTML> 

Output : This Script help you to show time and date. Mon Jul 08 2013 13:18:03

NOTE:THE TIME SHOW HERE IN THIS OUTPUT IS THE TIME WHEN I POST THIS ARTICLE.
Read more...
Wednesday, May 22, 2013

How To Use Hyperlink Tag in Html

0 comments
In this Post i will teach you how to create and use hyperlinks to your webpage.A hyperlink or link is a word, group of words, or image that you can click on to jump to another document.An unvisited link is underlined and blue.A visited link is underlined and purple.An active link is underlined and red.You can also set the target using target attribute which specifies where to open the linked document.You can also use the id attribute for creating a bookmark inside the Html Document.

For a Simple Link: <a href="url">Link text</a>

For Target Attribute: <a href="url" target="_blank">Visit Blank</a>

For ID Attribute: <a id="tips">Useful Tips Section</a>


The above tag and attributes are use in the example given below.

<html>
<head>
<title>
How To 99
</title>
</head>
<body>
This Is My First Blog.<br><a href ="http://www.lovetech.in">Full Mobile Phone Specification</a><br>

Target Attribute<br><a href="howto99.blogspot.com" target="_blank">How To 99</a><br>

<a id="http://howto99.blogspot.com/2013/05/how-to-make-momos-both-steamed-and-fried.html">Useful Tips For Making Momos</a></body>
</html>
Copy the above Code and Paste in your Notepad or Notepad++ and saves the code with .html like abc.html or whatever you want and run the code
Read more...
Sunday, May 19, 2013

How To Use Image Tag in Html

0 comments
Here in this post i will teach you that how to use  image tag in html.With the help of this tag you can insert images to your html web page.You can set the height and width of the image with the help of height and width attributes.You can also use the alternate attribute for displaying the text on the image.

  • For Height and Width of the image <img src="url" width="" height="">
  • For Alternate Text of the image <img src="url" alt="Image Text">

Here URL is the address of your image:

You can find the address of your image by right click of mouse and than open the image in your default browser.You can also find the address of the image which is on the server,just right click and than copy the image url and paste it in the image tag.

This tags are work in the body section only i.e. between <body>and</body> tag only.
The above tag and attributes are use in the example given below.

<html>
<head>
<title>
How To 99
</title>
</head>
<body>
<img src="url" alt="Image Text" width="" height="">
</body>
</html>

Copy the above Code and Paste in your Notepad or Notepad++ and saves the code with .html like abc.html or whatever you want and run the code.
Read more...

How To Use Bold,Italic and Underline Tag in Html

0 comments
Here in this post i will teach you that how to use bold,italic and underline tag in html.If you want your text in bold, italic or in underline than use these tags.

  • For Bold Text <b>Your Text </b>
  • For Italic Text <i>Your Text </i>
  • For Underline Text <u>Your Text </u>
These tags are work in the body section only i.e. between <body>and</body> tag only.
The above tags are use in the example given below


<html>
<head>
<title>
How To 99
</title>
</head>
<body>
<b>Bold-How To 99</b>
<i>italic-How To 99</i>
<u>underline-How To 99</u>
</body>
</html>

Copy the above Code and Paste in your Notepad or Notepad++ and saves the code with .html  like abc.html or whatever you want and run the code.

Read more...
Saturday, May 18, 2013

How To Make a Simple Html Web Page

0 comments
Hyper Text Markup Language (HTML) is the main markup language for creating web pages and other information that can be displayed in a web browser.Now you can also make or create these webpages with the help of this simple code given below.

Simple Html Webpage Code :
<! DOCTYPE html>
<html>
<head>
<title>
How To 99
</title>
</head>
<body>
Anything that you write in body section will display on the browser window
</body>
</html>
In the above code,
  • The DOCTYPE declaration defines the document type.
  • The text between <html> and </html> describes the web page.
  • The text between <title> and </title> is the title of your page.
  • The text between <body> and </body> will display on your web-browser window.
Read more...
Tuesday, May 7, 2013

How to calculate roots of Quadratic Equation using Javascript

0 comments
Quadratic Equations are of the form ax2 + bx + c = 0. To find roots(root1 and root2) of such an equation, we need to use the formula:
how to find Roots of Quadratic Equation: JavaScript
Roots of Quadratic Equation

Javascript code for calculating roots of quadratic equation is given below:

 <html>
<title>Root calculator</title>
<head>
    <script type="text/javascript">
    function roots()
    {
        var a = prompt("Enter value of a","");
        var b = prompt("Enter value of b","");
        var c = prompt("Enter value of c","");

        var root_part = Math.sqrt(b * b - 4 * a * c);
        var denom = 2 * a;

        var root1 = ( -b + root_part ) / denom;
        var root2 = ( -b - root_part ) / denom;

        document.write("1st root: "+root1+"<br />");
        document.write("2nd root: "+root2+"<br />");
    }
    </script>
    </head>
<body>
    <input type="button" onclick="roots()" value ="Root calculator" >
    </body>
</html>
 Demo for roots of Quadratic Equation using Javascript:
  • click the Root calculator button
  • simply enter the values of a, b & c
  • calculated roots will be shown
Read more...

Labels

 
How To 99 © 2013 How to 99 &

How to Tutorial in 99 Categories