<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Three2Tango &#187; Study JavaScript</title>
	<atom:link href="http://www.three2tango.com/category/techcorner/study-javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.three2tango.com</link>
	<description>Points To Ponder : The Latest news from the TechWorld,Automobiles,CellPhones and lots of useful Code Snippets</description>
	<lastBuildDate>Fri, 27 Jan 2012 09:03:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Study JavaScript Easy Part-4</title>
		<link>http://www.three2tango.com/techcorner/study-javascript-easy-part-4.html/</link>
		<comments>http://www.three2tango.com/techcorner/study-javascript-easy-part-4.html/#comments</comments>
		<pubDate>Fri, 01 May 2009 08:22:37 +0000</pubDate>
		<dc:creator>LG</dc:creator>
				<category><![CDATA[Study JavaScript]]></category>
		<category><![CDATA[Tech Corner]]></category>
		<category><![CDATA[java scripts]]></category>

		<guid isPermaLink="false">http://www.three2tango.com/?p=561</guid>
		<description><![CDATA[Previous
I found a few more things which am posting in here.This is the continuation of JavaScript OBJECTS
Date Objects
These are used to work with date,day,month,year,time etc.
Eg:1(To get the current date)
&#60;html&#62;
&#60;body&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
document.write(&#8220;Todays date:-&#8221;+Date( ));
&#60;/script&#62;
&#60;/body&#62;
&#60;/html&#62;
Eg:2(To get the day of a week)
&#60;html&#62;
&#60;body&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
var d=new Date();
document.write(&#8220;Today it is &#8221; + d.getDay( ));
&#60;/script&#62;
&#60;/body&#62;
&#60;/html&#62;
The above Eg: can be improvised a bit,check the Eg: below.
In Eg:2 the getDay( ) method returns an integer value equivalent to the day,in the Eg:3 it is more specific.
Eg:3
&#60;html&#62;
&#60;body&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
var d=new Date();
var weekday=new Array(7);
weekday[0]=&#8221;Sunday&#8221;;
weekday[1]=&#8221;Monday&#8221;;
weekday[2]=&#8221;Tuesday&#8221;;
weekday[3]=&#8221;Wednesday&#8221;;
weekday[4]=&#8221;Thursday&#8221;;
weekday[5]=&#8221;Friday&#8221;;
weekday[6]=&#8221;Saturday&#8221;;
document.write(&#8220;Today is &#8221; + weekday[d.getDay()]);
&#60;/script&#62;
&#60;/body&#62;
&#60;/html&#62;
Eg:4 (Clock)
&#60;html&#62;
&#60;head&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
function showTime()
{
var today=new Date();
var ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.three2tango.com/archives/301"><strong>Previous</strong></a><br />
I found a few more things which am posting in here.This is the continuation of <em><strong>JavaScript OBJECTS</strong></em></p>
<p><strong>Date Objects</strong><br />
These are used to work with date,day,month,year,time etc.</p>
<blockquote><p><strong>Eg:1</strong>(To get the current date)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(&#8220;Todays date:-&#8221;+Date( ));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<blockquote><p><strong>Eg:2</strong>(To get the day of a week)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var d=new Date();<br />
document.write(&#8220;Today it is &#8221; + d.getDay( ));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>The above Eg: can be improvised a bit,check the Eg: below.<br />
In Eg:2 the getDay( ) method returns an integer value equivalent to the day,in the Eg:3 it is more specific.</p>
<blockquote><p><strong>Eg:3</strong><br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var d=new Date();<br />
var weekday=new Array(7);<br />
weekday[0]=&#8221;Sunday&#8221;;<br />
weekday[1]=&#8221;Monday&#8221;;<br />
weekday[2]=&#8221;Tuesday&#8221;;<br />
weekday[3]=&#8221;Wednesday&#8221;;<br />
weekday[4]=&#8221;Thursday&#8221;;<br />
weekday[5]=&#8221;Friday&#8221;;<br />
weekday[6]=&#8221;Saturday&#8221;;<br />
document.write(&#8220;Today is &#8221; + weekday[d.getDay()]);<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><strong>Eg:4</strong> (Clock)</p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function showTime()<br />
{<br />
var today=new Date();<br />
var h=today.getHours();<br />
var m=today.getMinutes();<br />
var s=today.getSeconds();<br />
m=checkTime(m);<br />
s=checkTime(s);<br />
document.getElementById(&#8216;div1&#8242;).innerHTML=h+&#8221;:&#8221;+m+&#8221;:&#8221;+s;<br />
t=setTimeout(&#8216;showTime()&#8217;,500);<br />
}<br />
function checkTime(i)<br />
{<br />
if (i&lt;10)<br />
{<br />
i=&#8221;0&#8243; + i;<br />
}<br />
return i;<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body onload=&#8221;showTime()&#8221; &gt;<br />
&lt;div id=&#8221;div1&#8243;&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><strong>Math Objects</strong><br />
Is used for mathematical operations,it includes several mathematical <em>constants </em> and <em>methods</em>.</p>
<p><strong>CONSTANTS:</strong><br />
<strong>Math.PI</strong> &#8212;for the constant 3.14(22/7)<br />
<strong>Math.SQRT2</strong>&#8212;-Square root of 2<br />
<strong>Math.LN2</strong>&#8212;&#8212;-Natural Log of 2<br />
<strong>Math.LN10</strong>&#8212;&#8212;Natural Log of 10</p>
<p><strong>METHODS:</strong><br />
Copy the codes to a notepad and save as an html file and see the output.</p>
<li>Math.round( )</li>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(Math.round(1.60) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.round(1.50) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.round(1.49) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.round(-2.40) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.round(-2.60));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<li>Math.max( )</li>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(Math.max(3,9) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.max(-3,6) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.max(-1,-8) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.max(7.25,7.30));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<li>Math.min( )</li>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(Math.min(3,4) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.min(-2,3) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.min(-3,-5) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(Math.min(4.25,4.30));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Goto   <a href="http://www.three2tango.com/archives/301"><strong>Previous</strong></a> Post</p>
]]></content:encoded>
			<wfw:commentRss>http://www.three2tango.com/techcorner/study-javascript-easy-part-4.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Study JavaScript Easy Part-3</title>
		<link>http://www.three2tango.com/techcorner/study-javascript-easy-part-3.html/</link>
		<comments>http://www.three2tango.com/techcorner/study-javascript-easy-part-3.html/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 10:57:43 +0000</pubDate>
		<dc:creator>LG</dc:creator>
				<category><![CDATA[Study JavaScript]]></category>
		<category><![CDATA[Tech Corner]]></category>
		<category><![CDATA[java scripts]]></category>
		<category><![CDATA[javascript string sorting]]></category>

		<guid isPermaLink="false">http://www.three2tango.com/?p=301</guid>
		<description><![CDATA[Previous
JavaScript study Continued&#8230;.
Special Symbols in JavaScript
A backslash ( \ ) is used to add special symbols or characters in a javascript.The special symbols are quotes,newlines,tabs etc etc.
Eg:1(check difference between both codes)
document.write(&#8220;welcome to &#8220;ooty&#8221; nice to meet you&#8221;);
document.write(&#8220;welcome to\&#8221;ooty\&#8221; nice to meet you&#8221;);
Given below is a list of special characters that can be added to a text string with the help of a backslash sign.
\&#8217;          Single quote
\&#8221;          Double quote
\n     ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.three2tango.com/archives/257"><strong>Previous</strong></a><br />
JavaScript study Continued&#8230;.<br />
<strong>Special Symbols in JavaScript</strong><br />
A backslash ( \ ) is used to add special symbols or characters in a javascript.The special symbols are quotes,newlines,tabs etc etc.</p>
<p><strong>Eg:1</strong>(check difference between both codes)<br />
document.write(&#8220;welcome to &#8220;ooty&#8221; nice to meet you&#8221;);<br />
document.write(&#8220;welcome to\&#8221;ooty\&#8221; nice to meet you&#8221;);</p>
<p>Given below is a list of special characters that can be added to a text string with the help of a backslash sign.</p>
<p>\&#8217;          Single quote<br />
\&#8221;          Double quote<br />
\n         New line<br />
\b             BackSpace<br />
\&amp;             Ampersand</p>
<h4>JavaScript In Depth</h4>
<p>Believe it or not JS is an object oriented language.It allows our own objects and variable types.<br />
What is an object??<br />
An object is a special kind of data,it has properties and methods.Length is the property of a string.Methods are the actions that can be performed on objects.To change the size of a string,change its case etc etc are methods.<br />
I am writing down a few Eg:,which i think would help in one way or the other.</p>
<li><strong>String Objects</strong></li>
<blockquote><p><strong>Eg:2</strong>(To find the length of a string)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var txt=&#8221;lloyd&#8221;;<br />
document.write(txt.length);<br />
document.write(&#8220;&lt;p&gt;Lowercase: &#8221; + txt.toLowerCase() + &#8220;&lt;/p&gt;&#8221;);<br />
document.write(&#8220;&lt;p&gt;Uppercase: &#8221; + txt.toUpperCase() + &#8220;&lt;/p&gt;&#8221;);<br />
document.write(&#8220;&lt;p&gt;Fontcolor: &#8221; + txt.fontcolor(&#8220;Blue&#8221;) + &#8220;&lt;/p&gt;&#8221;);<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><em>Result is:</em><br />
5<br />
Lowercase: lloyd<br />
Uppercase: LLOYD<br />
Fontcolor: <span style="color: #0000ff;">lloyd</span></p>
<blockquote><p><strong>Eg:3</strong>(indexOf( ):-To find the position of a word)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var str=&#8221;india is mine&#8221;;<br />
document.write(str.indexOf(&#8220;india&#8221;) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(str.indexOf(&#8220;is&#8221;) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(str.indexOf(&#8220;mine&#8221;) + &#8220;&lt;br /&gt;&#8221;);<br />
document.write(str.indexOf(&#8220;how&#8221;));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><em>Result:</em><br />
0<br />
6<br />
9<br />
-1</p>
<p><em>Note:</em>The -1 in the result indicates that no such word in the string.</p>
<blockquote><p><strong>Eg:4</strong>(replace( ):-To replace characters in a string)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var str=&#8221;Visit Us&#8221;;<br />
document.write(str.replace(/Us/,&#8221;http:\\\\www.three2tango.com&#8221;));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<li><strong>Array Objects</strong></li>
<p>The use is same as normal arrays in C,C++.It is used to store multiple values in a single variable.I will come up with Eg: so that it is easily understood.</p>
<blockquote><p><strong>Eg:5</strong>(How to create an array)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var mypassion = new Array();<br />
mypassion[0] = &#8220;Dot net&#8221;;<br />
mypassion[1] = &#8220;C#&#8221;;<br />
mypassion[2] = &#8220;sql&#8221;;<br />
for (i=0;i&lt;mypassion.length;i++)<br />
{<br />
document.write(mypassion[i] + &#8220;&lt;br /&gt;&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><strong>Eg:6</strong>(Concatinating arrays)</p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var t = new Array(3);<br />
t[0] = &#8220;I&#8221;;<br />
t[1] = &#8220;Love&#8221;;<br />
t[2] = &#8220;You&#8221;;<br />
var s = new Array(3);<br />
s[0] = &#8220;Because&#8221;;<br />
s[1] = &#8220;You are&#8221;;<br />
s[2] = &#8220;Good&#8221;;<br />
document.write(t.concat(s));<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><em>Result :</em><br />
I,Love,You,Because,You are,Good</p>
<p><em>Note:</em>In the above Eg: t,s are 2 arrays of size 3 each,they are concatenated using the method .&#8221;concat( )&#8221;.</p>
<blockquote><p><strong>Eg:7</strong>(To sort an array)<br />
&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var arr = new Array(6);<br />
arr[0] = &#8220;vivek&lt;br/&gt;&#8221;;<br />
arr[1] = &#8220;dileep&lt;br/&gt;&#8221;;<br />
arr[2] = &#8220;shefeek&lt;br/&gt;&#8221;;<br />
arr[3] = &#8220;hari&lt;br/&gt;&#8221;;<br />
arr[4] = &#8220;arun&lt;br/&gt;&#8221;;<br />
arr[5] = &#8220;joseph&lt;br/&gt;&#8221;;<br />
document.write(arr + &#8220;&lt;br /&gt;&#8221; );<br />
document.write(&#8220;sorted list&lt;br/&gt;&#8221;)<br />
document.write(arr.sort());<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><em>Result:</em></p>
<p>vivek<br />
,dileep<br />
,shefeek<br />
,hari<br />
,arun<br />
,joseph</p>
<p>sorted list<br />
arun<br />
,dileep<br />
,hari<br />
,joseph<br />
,shefeek<br />
,vivek</p>
<p><em>Note:</em>The method used to sort an array is shown above,it will sort a string array in alphabetical order.</p>
<p><strong>Goto </strong><a href="http://www.three2tango.com/archives/257"><strong>Prev</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.three2tango.com/techcorner/study-javascript-easy-part-3.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript study Part-2</title>
		<link>http://www.three2tango.com/techcorner/javascript-study-part-2.html/</link>
		<comments>http://www.three2tango.com/techcorner/javascript-study-part-2.html/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 11:14:57 +0000</pubDate>
		<dc:creator>LG</dc:creator>
				<category><![CDATA[Study JavaScript]]></category>
		<category><![CDATA[Tech Corner]]></category>
		<category><![CDATA[java scripts]]></category>

		<guid isPermaLink="false">http://www.three2tango.com/?p=257</guid>
		<description><![CDATA[Goto Prev Next
JavaScript study continued. . . . .
PopUp Boxes
There are three types of popup boxes
1)Alert
Is used to make sure the user is interacting properly and also to make sure information comes through the user.
Eg:1(to show alert popup box)
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;Untitled Page&#60;/title&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
function display_alert()
{
alert(&#8220;I am an alert popup box&#8221;+&#8217;\n&#8217;+&#8221;and this is how line breaks are used&#8221;);
}
&#60;/script&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;div&#62;
&#60;input type=&#8221;button&#8221; onclick=&#8221;display_alert()&#8221; value=&#8221;Show ME&#8221; /&#62;
&#60;/div&#62;
&#60;/body&#62;
&#60;/html&#62;
2)Confirm
This is used when we want the user to confirm,or if we want him to accept something.This popup will come with 2 options OK or CANCEL.
Eg:2(Confirm popup box)
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;Untitled Page&#60;/title&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
function display_confirm()
{
var loy=confirm(&#8220;Press ...]]></description>
			<content:encoded><![CDATA[<p><strong>Goto<a href="http://www.three2tango.com/archives/category/techcorner/study-javascript"> Prev</a> <a href="http://www.three2tango.com/archives/301">Next</a></strong></p>
<p>JavaScript study continued. . . . .<br />
<strong>PopUp Boxes</strong><br />
There are three types of popup boxes<br />
1)<strong>Alert</strong><br />
Is used to make sure the user is interacting properly and also to make sure information comes through the user.</p>
<blockquote><p><strong>Eg:1</strong>(to show alert popup box)<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Untitled Page&lt;/title&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function display_alert()<br />
{<br />
alert(&#8220;I am an alert popup box&#8221;+&#8217;\n&#8217;+&#8221;and this is how line breaks are used&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div&gt;<br />
&lt;input type=&#8221;button&#8221; onclick=&#8221;display_alert()&#8221; value=&#8221;Show ME&#8221; /&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>2)<strong>Confirm</strong><br />
This is used when we want the user to confirm,or if we want him to accept something.This popup will come with 2 options OK or CANCEL.</p>
<blockquote><p><strong>Eg:2</strong>(Confirm popup box)<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Untitled Page&lt;/title&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function display_confirm()<br />
{<br />
var loy=confirm(&#8220;Press a button&#8221;);<br />
if (loy==true)<br />
{<br />
document.write(&#8220;You pressed OK!&#8221;);<br />
}<br />
else<br />
{<br />
document.write(&#8220;You pressed Cancel!&#8221;);<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;div&gt;<br />
&lt;input type=&#8221;button&#8221; onclick=&#8221;display_confirm()&#8221; value=&#8221;Show ME&#8221; /&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>3)<strong>Prompt Box</strong><br />
Is used when we want the user to be prompted before entering a page.This restricts the user from continuing without giving out a data.The prompt box is having 2 options &#8220;OK&#8221; or  &#8220;CANCEL&#8221; ,OK will return the value in the box and CANCEL returns null.</p>
<blockquote><p><strong>Eg:3</strong>(Prompt box)<br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function display_prompt()<br />
{<br />
var name=prompt(&#8220;Please enter your name&#8221;);<br />
document.write(&#8220;Hello &#8221; + name + &#8220;Hope this helps you&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;input type=&#8221;button&#8221; onclick=&#8221;display_prompt()&#8221; value=&#8221;Display a prompt box&#8221; /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><em>Notes:</em><br />
Try these codes in visual studio and find the results,this code works if you save as html also,but &#8220;document.write&#8221; is not  working dont know why.<br />
<strong>FUNCTIONs In JavaScript</strong><br />
Function can be placed inside the &#8220;head&#8221; or &#8220;body&#8221; ,But to make sure it is read and loaded it is wise to place the function inside the &#8220;head&#8221; tag.A function contains a code which is executed on its call or in the trigger of an event.Eg:1,2,3 consists of functions.</p>
<p><strong>Function Definition:</strong><br />
<em>Syntax: for parameterised function</em><br />
<em>Function functionname(var1,var2)<br />
{<br />
statements<br />
}</em></p>
<p>For a function with no parameters the function name is followed by an opening and closing parenthesis.<br />
<em>Syntax:<br />
Function functionname()<br />
{  }</em></p>
<p><strong>Eg:4</strong>How to use a return statement in a function&#8230;</p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function myFunction()<br />
{<br />
var name=prompt(&#8220;Entr name&#8221;);<br />
return (name);<br />
}<br />
&lt;/script&gt;</p>
<p>&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(myFunction());<br />
&lt;/script&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Try&#8230;.Catch<br />
Another important thing i would like to mention in here is use of try &amp; catch in JavaScript.<br />
The try&#8230;catch statement allows us to debug a code for errors. The try block contains the code to be run, and the catch block contains the code to be executed if an error occurs.</p>
<p><strong>Eg:5(For try&#8230;.catch)</strong></p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var msg=&#8221;";<br />
function message()<br />
{<br />
try<br />
{<br />
adddlert(&#8220;Welcome guest!&#8221;);<br />
}<br />
catch(err)<br />
{<br />
msg=&#8221;There was an error on this page.\n\n&#8221;;<br />
msg+=&#8221;Error description: &#8221; + err.description + &#8220;\n\n&#8221;;<br />
msg+=&#8221;Click OK to continue.\n\n&#8221;;<br />
alert(msg);<br />
}<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;input type=&#8221;button&#8221; value=&#8221;View message&#8221; onclick=&#8221;message()&#8221; /&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>In the above <em>eg:</em> inside the &#8220;try&#8221; block the &#8220;alert&#8221; is mispelled,which will result in showing the alert message inside the &#8220;catch&#8221; block.Correct it and check it once more.And find the difference.<br />
<strong>Goto<a href="http://www.three2tango.com/archives/category/techcorner/study-javascript"> Prev</a> <a href="http://www.three2tango.com/archives/301">Next</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.three2tango.com/techcorner/javascript-study-part-2.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Study Java Script Easy</title>
		<link>http://www.three2tango.com/techcorner/study-javascript/study-java-script-easy.html/</link>
		<comments>http://www.three2tango.com/techcorner/study-javascript/study-java-script-easy.html/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 11:29:17 +0000</pubDate>
		<dc:creator>LG</dc:creator>
				<category><![CDATA[Study JavaScript]]></category>
		<category><![CDATA[java scripts]]></category>

		<guid isPermaLink="false">http://www.three2tango.com/?p=213</guid>
		<description><![CDATA[JavaScript is a scripting language,designed to add interactivity to an html page.
The official name of javascript is ECMA script .ECMA-262 is the official JavaScript standard.The standard is based on JavaScript (Netscape) and JScript (Microsoft).
How to put javascript into an HTML,??
To insert a JavaScript into an HTML page, we use the &#60;script&#62; tag.Inside the
&#60;script&#62; tag we use the type attribute to define the scripting language.
Eg:1
&#60;body&#62;
&#60;script type=&#8221;text/javascript&#8221;&#62;
document.write(&#8220;Hello World!&#8221;);
&#60;/script&#62;
&#60;/body&#62;
JavaScripts can be put in &#60;head&#62; section or &#60;body&#62; also.JavaScripts in the body part will be executed onlt when the page loads.JavaScripts in the head ...]]></description>
			<content:encoded><![CDATA[<p>JavaScript is a scripting language,designed to add interactivity to an html page.<br />
The official name of javascript is ECMA script .ECMA-262 is the official JavaScript standard.The standard is based on JavaScript (Netscape) and JScript (Microsoft).</p>
<p>How to put javascript into an HTML,??<br />
To insert a JavaScript into an HTML page, we use the &lt;script&gt; tag.Inside the<br />
&lt;script&gt; tag we use the type attribute to define the scripting language.</p>
<p><strong>Eg:1</strong></p>
<blockquote><p><strong></strong>&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
document.write(&#8220;Hello World!&#8221;);<br />
&lt;/script&gt;<br />
&lt;/body&gt;</p></blockquote>
<p>JavaScripts can be put in &lt;head&gt; section or &lt;body&gt; also.JavaScripts in the body part will be executed onlt when the page loads.JavaScripts in the head section will be executed only when CALLED.<strong></strong></p>
<p><strong>Eg:2( Describing JS in &lt;head&gt; section)</strong></p>
<blockquote><p><strong></strong>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
function message()<br />
{<br />
alert(&#8220;This alert box was called with the onload event&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&#8221;message()&#8221;&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><strong>Eg:3 (Describing JS in &lt;body&gt;  portion)</strong><br />
same as Eg:1</p>
<p>Script can be put in both head and body sections.<br />
Comments in JS is used to increase readability of the code.Single line comments use //.</p>
<p><strong>Eg4:(Use of single line comments)</strong></p>
<p><strong></strong><br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
// This will write a header:<br />
document.write(&#8220;&lt;h1&gt;This is a header&lt;/h1&gt;&#8221;);<br />
&lt;/script&gt;</p>
<p>For multi line commenting (/*   */ ) is used.</p>
<p><strong>Variables in JavaScript</strong><br />
JavaScript variables are used to hold values or expressions.Naming conventions are normal.Variable names are case sensitive (a and A are different).Variable names must begin with a letter or the underscore character.<br />
<strong>Declaring variable in JavaScript</strong><br />
You can declare JavaScript variables with the &#8216;var&#8217; statement:</p>
<p><strong>Eg:</strong><br />
var x;<br />
var sample;<br />
<strong>Redeclaring a JavaScript variable, will not lose its original value.</strong><br />
<strong>Eg:</strong><br />
var a=5;<br />
var a;<br />
The redeclaration of  &#8216;a&#8217; wont lose its value &#8217;5&#8242; in the above Eg.<br />
<strong>Operators in JavaScript</strong><br />
The operator = is used to assign values, + is used to add values,% is for modulus operation,++ for increment operation,&#8211; for decrement operation.</p>
<p><strong>Comparison Operators:</strong><br />
&lt;,&gt;,&lt;=,&gt;=,==,!= etc are as usual<br />
A new thing is &#8220;===&#8221;,it means exactly equal to value and type.<br />
I will explain this with an<br />
Eg:<br />
x=3;<br />
x===3 is true.<br />
x===&#8221;3&#8243; is false.<br />
<strong>Eg.5(Use of conditional operator)</strong><br />
if (age&lt;21)<br />
document.write(&#8220;Cant buy this&#8221;);<br />
<strong>Logical Operators:</strong><br />
&amp;&amp;,||,!  are same as that of other languages.<br />
<strong>Conditional Operator:</strong><br />
This assigns a value to a variable based on a condition.<br />
Syntax:variablename=(condition)?value1:value2</p>
<p><strong>Eg:6(if statement)Simply copy this to a notepad save it as an html and open in your browser.</strong></p>
<blockquote><p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
var d = new Date();<br />
var time = d.getHours();<br />
var time1=d.getMinutes();<br />
if (time &lt; 12 &amp;&amp; time1 &lt; 50 )<br />
{<br />
document.write(&#8220;&lt;b&gt;Good morning&lt;/b&gt;&#8221;);<br />
}<br />
else<br />
{<br />
document.write(&#8220;&lt;t&gt;Time is past 12.50&lt;/t&gt;&#8221;);<br />
}<br />
&lt;/script&gt;<br />
&lt;p&gt;<br />
This example demonstrates the If statement.<br />
&lt;/p&gt;<br />
&lt;p&gt;<br />
If the time on your browser is less than 12,<br />
you will get a &#8220;Good morning&#8221; greeting.<br />
&lt;/p&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p><strong>Notes:</strong><br />
1) It is case sensitive.<br />
2) Semicolon is optional in javascript.<br />
3) It uses curly braces to seperate blocks of code.<br />
4)If you add a number and a string, the result will be a string.</p>
<p><strong>Goto   <a href="http://www.three2tango.com/archives/257">Next</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.three2tango.com/techcorner/study-javascript/study-java-script-easy.html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

