<?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>Roshan Bhattarai's Blog -  A blog about PHP, Ajax, JavaScript, CSS and Web 2.0 &#187; jquery</title>
	<atom:link href="http://roshanbh.com.np/category/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://roshanbh.com.np</link>
	<description>Useful Tutorials, Scripts , Tips, and Resources for all PHP and Ajax beginners and experts .</description>
	<lastBuildDate>Thu, 10 Jun 2010 11:38:45 +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>Sleek and Smooth animated menu using jQuery</title>
		<link>http://roshanbh.com.np/2009/07/sleek-smooth-animated-menu-jquery.html</link>
		<comments>http://roshanbh.com.np/2009/07/sleek-smooth-animated-menu-jquery.html#comments</comments>
		<pubDate>Tue, 28 Jul 2009 09:54:55 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[animation]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=332</guid>
		<description><![CDATA[Today, I&#8217;m going to show you something interesting with jQuery. Yesterday I was thinking something to post something programming related stuff  in blog after long time and I came across a website, whose menu impressed me a lot. But checking it in a while, I found it it was built using mootools.  Since it was [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2009%2F07%2Fsleek-smooth-animated-menu-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2009%2F07%2Fsleek-smooth-animated-menu-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Today, I&#8217;m going to show you something interesting with jQuery. Yesterday I was thinking something to post something programming related stuff  in blog after long time and I came across a website, whose menu impressed me a lot. But checking it in a while, I found it it was built using mootools.  Since it was in mootools, I thought of replicating it in jQuery. I have two example of similar menu, first using jQuery core and CSS and another uses <a href="http://gsgd.co.uk/sandbox/jquery/easing/" target="_blank">jQuery easing plugin</a> to give bounce effect to the same menu.And I&#8217;ve added one more example which I though would be nice menu to show you guys.<span id="more-332"></span></p>
<p><strong><a title="sleek and smooth jquery menu" href="http://roshanbh.com.np/examples/sleek-smooth-hover-menu/" target="_blank">VIEW DEMO</a></strong></p>
<p>First of let me start, with the images which i&#8217;ve used in the background to create the first two menus.</p>
<p><img class="alignnone" style="border:none;" title="smooth jquery menu" src="http://roshanbh.com.np/examples/sleek-smooth-hover-menu/bg.png" alt="smooth jquery menu" width="192" height="25" /> and <img class="alignnone" style="border:none;" title="sleek jquery menu" src="http://roshanbh.com.np/examples/sleek-smooth-hover-menu/bg-right.png" alt="sleek jquery menu" width="8" height="25" /></p>
<p style="text-align: justify;">Please note that the please keep the left image as big as possible if you&#8217;re menu text can be long.</p>
<p style="text-align: justify;">Now, let&#8217;s look at the html code</p>
<h4>Html code for the animated jquery menu</h4>
<pre class="prettyprint" style="overflow:auto">&lt;ul class="nav" id="nav1"&gt;
   &lt;li class="first"&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Portfolio&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;About us&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Blog&lt;/a&gt;&lt;/li&gt;
   &lt;li class="last"&gt;&lt;a href="#"&gt;Tutorials&lt;/a&gt;&lt;/li&gt;
   &lt;li class="bg"&gt;&lt;div class="left"&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p style="text-align: justify;">All the list elements are fairly simple and the list with class &#8220;<strong>bg</strong>&#8221; is the one which holds the background image for the menu. The code is same for the first and second example but for the third example we use list with class <strong>ybg </strong>instead of bg.</p>
<pre style="border: 1px solid #888888; padding: 2px;"> &lt;li class="ybg"&gt;&lt;/li&gt;</pre>
<h4>CSS code for the smooth jQuery menu</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">ul.nav {</span> <span style="color: #000080;">list-style:none;  overflow:hidden;</span>  <span style="color: #ff00ff;">}

ul.nav li {</span> <span style="color: #000080;">float:left; height:39px; background-color:#000;  padding:0 5px;</span> <span style="color: #ff00ff;"> }

ul.nav li.first {</span>
  <span style="color: #000080;">-moz-border-radius-topleft:9px; -webkit-border-top-left-radius:9px;
  -moz-border-radius-bottomleft:9px;  -webkit-border-bottom-left-radius:9px;</span>
<span style="color: #ff00ff;">}

ul.nav li.last {</span>
<span style="color: #000080;">-moz-border-radius-topright:9px; -webkit-border-top-right-radius:9px;
-moz-border-radius-bottomright:9px; -webkit-border-bottom-right-radius:9px;</span>
<span style="color: #ff00ff;">}

ul.nav li.bg {</span>
  <span style="color: #000080;"> margin:7px 0px 0px 3px; padding-right:8px; position:absolute;
   z-index:50; left:155px; width:60px; background:url(bg-right.png) no-repeat right top;</span>
<span style="color: #ff00ff;">}

ul.nav li .left {</span><span style="color: #000080;"> background:url(bg.png) no-repeat left top; height:39px; </span> <span style="color: #ff00ff;">}

ul.nav li a {</span>
  <span style="color: #000080;">padding:8px 20px;  color:#FFF; font-size:18px; font-weight:bold; display:block;
  text-decoration:none; z-index:100; position:relative;</span>
<span style="color: #ff00ff;">}

ul.nav li.ybg {</span>
  <span style="color: #000080;">background-color:#FB0; position:absolute; z-index:50;
  left:165px; width:55px; height:4px; margin-top:6px;</span>
<span style="color: #ff00ff;">}</span></pre>
<p style="text-align: justify;">As you can see there, I&#8217;ve used CSS3 rounded corners for the first and last elements of list(obviously doesn&#8217;t work IE). Furthermore, the list with class <strong>bg</strong> is used for the first and second menu examples where the image is used in the background and which moves around on mouse hover on menu with sleek effect. Please note that this list must be positioned <span style="color: #800000;">absolutely</span>.</p>
<p style="text-align: justify;">The <strong>ybg</strong> class is used for the background effect for the third menu in the example, which first moves to the menu which has current mouse position and then starts sliding down.<br />
After this, let&#8217;s get into jQuery code for providing the sleek effect for the hover menu.</p>
<h4>jQuery code for animation in the  on menu</h4>
<pre class="prettyprint" style="overflow:auto">$('#nav1 li a').hover(function()
{
  var offset=$(this).offset();
  var thiswidth =$(this).width()+13;
  $('#nav1 li.bg').stop().animate({left:offset.left+"px",width:thiswidth+"px"},600);
},
function()
{
  $('#nav1 li.bg').stop().animate({left:"155px",width:"60px"},600);
});</pre>
</p>
<p style="text-align: justify;">The above is the code for the first menu. You can see that on the hover effect of anchor, first we&#8217;ve calculated the offset of menu and also width of the anchor element. Then, finally used animate function of jQuery to move the menu and increse the width of the background to create the nice and sleek effect.</p>
<p style="text-align: justify;">As you can see the second function of hover menu, which is called when mouse is released from the anchor, just reset back the menu to it&#8217;s original position.</p>
<p style="text-align: justify;">The code is exactly same for the second menu except the following line,</p>
<pre class="prettyprint" style="overflow:auto">$('#nav3 li.bg').stop().animate({left:"155px",width:"60px"},600,'easeOutBounce');</pre>
<p style="text-align: justify;">You can see the difference easily where I&#8217;ve used <strong>easeOutBounce</strong> easing effect for the bounce out effect when mouse is released form the menu.</p>
<pre class="prettyprint">$('#nav2 li a').hover(function()
{
  var offset=$(this).offset();
  var thiswidth =$(this).width()+13;
  $('#nav2 li.ybg').stop().animate({left:offset.left+9+"px",width:thiswidth+"px"},400,function(){
     $(this).animate({height:"28px"},150);
  });
},
function()
{
   $('#nav2 li.ybg').stop().animate({height:"4px"},150,function(){
      $(this).animate({left:"165px",width:"55px"},600,'easeOutBounce');
   });
});</pre>
<p style="text-align: justify;">And you can see in the above code of the third menu, first of all the menu gets slided to the current position of menu and then the height of the background gets increased to 28px, giving a nice effect. And when mouse is released from the menu, the same things happens but in the reverse order.</p>
<p style="text-align: justify;"><strong><a title="sleek and smooth jquery menu" href="http://roshanbh.com.np/codes/sleek-smooth-hover-menu.zip">DOWNLOAD SOURCE CODE</a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=332&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2009/07/sleek-smooth-animated-menu-jquery.html/feed</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
		<item>
		<title>Model File upload overlay box using jQuery and Thickbox</title>
		<link>http://roshanbh.com.np/2008/10/model-file-upload-overlay-box-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/10/model-file-upload-overlay-box-jquery.html#comments</comments>
		<pubDate>Sat, 25 Oct 2008 18:17:02 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[modal]]></category>
		<category><![CDATA[overlay]]></category>
		<category><![CDATA[thickbox]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=303</guid>
		<description><![CDATA[Few times back, sNare asked me how do display wordpress like overlay box where you can pass the variables when you click on the link and manipulate simultaneous actions in the overlay until user choose to close it. Today, I&#8217;ve come up with the solution of this with model upload overlay box using thickbox, a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fmodel-file-upload-overlay-box-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fmodel-file-upload-overlay-box-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Few times back, sNare asked me how do display wordpress like overlay box where you can pass the variables when you click on the link and manipulate simultaneous actions in the overlay until user choose to close it. Today, I&#8217;ve come up with the solution of this with model upload overlay box using <a href="http://jquery.com/demo/thickbox/">thickbox</a>, a jquery plugin. I&#8217;ve used the Iframe content of thickbox while displaying the box as modal box.</p>
<p><span id="more-303"></span><br />
<strong><a href="http://roshanbh.com.np/examples/file-upload-overlay-jquery" target="_blank">LIVE DEMO </a></strong></p>
<h4>How to use the thickbox as modal overlay box?</h4>
<p>Let&#8217;s look at the step by step to use thickbox for passing variables.</p>
<p>First of all, we have to include jQuery JavaScript Library to our page,</p>
<pre class="prettyprint" style="overflow:auto">&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;</pre>
<p>After this, include the <a href="http://jquery.com/demo/thickbox/">thickbox</a> plugin of jQuery,</p>
<pre class="prettyprint" style="overflow:auto">&lt;script type="text/javascript" src="thickbox-compressed.js"&gt;&lt;/script&gt;</pre>
<p>There is a CSS for using thickbox which also need to linked to the current page,</p>
<pre class="prettyprint" style="overflow:auto">&lt;link rel="stylesheet" href="thickbox.css" type="text/css" media="screen" /&gt;</pre>
<p>Now, let&#8217;s look at the anchor tag which passes the variables to overlay box and keep the overlay at top no matter how many simultaneous accesses occur in the box.</p>
<pre class="prettyprint" style="overflow:auto">&lt;a href="file_upload.php?post_id=5&amp;TB_iframe=true&amp;height=200&amp;width=300&amp;modal=true" class="thickbox" &gt;&lt;strong&gt;Upload Files&lt;/strong&gt;&lt;/a&gt;</pre>
<p>If you want to know how to use the thickbox, then you can checkout their home page which contains good documentation. The main point is, <span style="color: #000080;">class=&#8217;thickbox&#8217; </span>must be used for the displaying the content in overlay.</p>
<h4>How to pass variables to overlay box (thickbox)?</h4>
<p>If you look at the href attribute of anchor tag, you can see clearly that I&#8217;ve passed <span style="color: #003366;">post_id</span> variable with value <span style="color: #003366;">5</span> to <span style="color: #000080;">file_upload.php</span>, which can be easily fetched from PHP using <span style="color: #000080;">$_GET['post_id']</span>.</p>
<h4>How to make overlay box stay opened on simultaneous access?</h4>
<p>Now this is part which many people has asked me how to do it. To use thickbox in this fashion, you&#8217;ve to use it in iframe content mode.The following property of thickbox make it remained open on simultaneous access,</p>
<pre class="prettyprint" style="overflow:auto">TB_iframe=true</pre>
<p>Furthermore, We&#8217;ve used the following property to display the overlay box as modal box.</p>
<pre class="prettyprint" style="overflow:auto">modal=true</pre>
<p><strong><a href="http://roshanbh.com.np/codes/file-upload-overlay-jquery.zip">DOWNLOAD SOURCE CODE </a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=303&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/10/model-file-upload-overlay-box-jquery.html/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>jQuery plugin: word-counter for textarea</title>
		<link>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html</link>
		<comments>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html#comments</comments>
		<pubDate>Mon, 20 Oct 2008 11:43:50 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[jquery plugin]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=299</guid>
		<description><![CDATA[Sorry friends on the way of move to new home I&#8217;ve been lost from the blog as I didn&#8217;t have internet connection for few last weeks. Now, I&#8217;m back and I try to be regular as much as I can. Inspired from the new feature of wordpress 2.6.x which displays word count of each post, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fjquery-plugin-word-counter-textarea.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F10%2Fjquery-plugin-word-counter-textarea.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Sorry friends on the way of move to new home I&#8217;ve been lost from the blog as I didn&#8217;t have internet connection for few last weeks. Now, I&#8217;m back and I try to be regular as much as I can. Inspired from the new feature of wordpress 2.6.x which displays word count of each post, I&#8217;ve developed jQuery plugin to display word-count of Textarea. Please note that it is <span style="color: #000080;">word count plugin</span> not <span style="text-decoration: line-through;">character counter</span>.<br />
<span id="more-299"></span><br />
<a href="http://roshanbh.com.np/examples/jquery-word-count-plugin/" target="_blank"><strong>LIVE  DEMO </strong></a></p>
<h4>Jquery plugin: Word-count code</h4>
<pre class="prettyprint" style="overflow:auto">jQuery.fn.wordCount = function(params)
{
   var p =  {
   counterElement:"display_count"
   };
   var total_words;

  if(params) {
      jQuery.extend(p, params);
   }

  //for each keypress function on text areas
  this.keypress(function()
  {
    total_words=this.value.split(/[\s\.\?]+/).length;
    jQuery('#'+p.counterElement).html(total_words);
   });
};</pre>
<p><a href="http://roshanbh.com.np/codes/jquery.wordcount.js" target="_blank"><strong>VIEW PLUGIN&#8217;S CODE</strong></a></p>
<p>As you can in the above code, I assume that each words of a paragraph are separated by the either spaces or dots(.) . Please have your suggestion if i can more characters to improve this plugin.</p>
<h4>How to use this plugin?</h4>
<p>Well, you can guess that a Textarea is needed of whose words are counted and another element like div or span needed to display the word count.</p>
<p>For example, the below HTML code contains Textarea (whose total word is counted) and span (for displaying counted word).</p>
<pre class="prettyprint" style="overflow:auto">&lt;textarea name="word_count" id="word_count" cols="30" rows="6"&gt;&lt;/textarea&gt;
Total word Count : &lt;span id="display_count"&gt;0&lt;/span&gt;</pre>
<p>Remember that the id of text area is &#8220;<span style="color: #000080;">word_coun</span>t&#8221; and &#8220;<span style="color: #000080;">display_count</span>&#8220;.</p>
<p>Now, let look at the jQuery code for displaying word count of text area , note that we are calling the function wordCount() which we&#8217;ve just developed in the plugin of jQuery.</p>
<pre class="prettyprint">$('#word_count').wordCount();</pre>
<p><strong>Note: </strong>display_count  is default id of element which is already defined in the plugin if you want to use the different id of elment then you&#8217;ve to override the value of variable <strong>counterElement</strong> which contains the <span style="color: #000080;">id</span> of element displaying word count.</p>
<pre class="prettyprint">$('#word_count').wordCount({counterElement:"word_counter"});</pre>
<p><a href="http://roshanbh.com.np/codes/jquery-word-count.zip"><strong>DOWNLOAD EXAMPLE CODE </strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=299&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/10/jquery-plugin-word-counter-textarea.html/feed</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Table row manipulation using jQuery JavaScript</title>
		<link>http://roshanbh.com.np/2008/09/table-row-manipulation-jquery-javascript.html</link>
		<comments>http://roshanbh.com.np/2008/09/table-row-manipulation-jquery-javascript.html#comments</comments>
		<pubDate>Thu, 18 Sep 2008 06:33:27 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=277</guid>
		<description><![CDATA[In a jQuery tutorial, I&#8217;ve shown how to display different color in alternate row of table using jQuery. This time I&#8217;ve come up with advanced version of same tutorial where you can add different color in alternate row of table whereas you can display a different color when mouse moves over each row of table [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F09%2Ftable-row-manipulation-jquery-javascript.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F09%2Ftable-row-manipulation-jquery-javascript.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In a jQuery tutorial, I&#8217;ve shown how to display <a href="http://roshanbh.com.np/2008/03/different-color-alternate-row-jquery.html">different color in alternate row of table using jQuery</a>. This time I&#8217;ve come up with advanced version of same tutorial where you can add different color in alternate row of table whereas you can display a different color when mouse moves over each row of table furthermore you can assign a different color to table row when mouse is clicked in the table row.</p>
<p style="text-align: justify;"><span id="more-277"></span><a href="http://roshanbh.com.np/examples/table-manipulation-jquery/" target="_blank"><br />
<strong>View Live Demo</strong></a></p>
<h4>HTML code for table row filtering using jQuery</h4>
<pre class="prettyprint" style="overflow:auto">&lt;table id="mytable" border="0" width="40%"&gt;
  &lt;tr&gt;&lt;td&gt;Michael&lt;/td&gt;&lt;td&gt;21&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Sam&lt;/td&gt;&lt;td&gt;22&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</pre>
<p>As you can see there is nothing special in the above code where I&#8217;ve  defined a table with id &#8220;mytable&#8221;.</p>
<h4>CSS code for table row manipulation</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.oddtr
{</span>
	<span style="color: #000080;">background-color:#EFF1F1;</span>
<span style="color: #ff00ff;">}
.eventr
{</span>
	<span style="color: #000080;">background-color:#F8F8F8;</span>
<span style="color: #ff00ff;">}
.trover
{</span>
	<span style="color: #000080;">background-color: #0099CC;</span>
<span style="color: #ff00ff;">}
.trclick
{</span>
	<span style="color: #000080;">background-color: #00CCCC;</span>
<span style="color: #ff00ff;">}</span></pre>
<p>As you can above code, I&#8217;ve defined four different classes with four different color. <span style="color: #000080;">oddtr</span> for coloring the odd row of table, similarly <span style="color: #000080;">eventr</span> for even row of table then <span style="color: #000080;">trover</span> class for displaying different color when mouse moves over the table row i.e on mouse over event. Finally, <span style="color: #000080;">trclick</span> class for displaying different color of the row when mouse is clicked in the table row. Note that you can change these colors according to your choice.</p>
<h4>jQuery&#8217;s JavaScript code for table row manipulation</h4>
<pre class="prettyprint" style="overflow:auto">//these two line adds the color to each different row
$("#mytable tr:even").addClass("eventr");;
$("#mytable tr:odd").addClass("oddtr");;
//handle the mouseover , mouseout and click event
$("#mytable tr").mouseover(function() {$(this).addClass("trover");}).mouseout(function() {$(this).removeClass("trover");}).click(function() {$(this).toggleClass("trclick");});</pre>
<p>The first two line of jQuery adds two differnt classes to the alternate rows of  table with id &#8220;<span style="color: #000080;">mytable</span>&#8220;. The last line of jQuery acts for three differnt on the table row. When mouse is moved over the table row <span style="color: #000080;">trover</span> class is added to that table row. When mouse moves away form that table row trover class is removed from that particular row and finally when mouse is clicked on tha particular row it toggles the class <span style="color: #000080;">trclick</span> on that particular row.</p>
<p><a href="http://roshanbh.com.np/codes/table-manipulation-jquery.zip" target="_blank"><strong>Download Full Source Code</strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=277&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/09/table-row-manipulation-jquery-javascript.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How to display pop-up message on mouse clicked position using jQuery</title>
		<link>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html#comments</comments>
		<pubDate>Mon, 04 Aug 2008 16:39:20 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[message box]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=203</guid>
		<description><![CDATA[Yesterday, my friend Sujit asked me how can we get the mouse clicked position and display the pop-up message in that mouse clicked position using jQuery.Today, I&#8217;ve come up with the tutorial for the solution of this problem. In this tutorial, you&#8217;ll see how to display the pop-up message in mouse clicked position using jQuery. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fpop-up-message-mouse-clicked-position-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F08%2Fpop-up-message-mouse-clicked-position-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Yesterday, my friend <a href="http://sks.com.np" target="_blank">Sujit</a> asked me how can we get the mouse clicked position and display the pop-up message in that mouse clicked position using jQuery.Today, I&#8217;ve come up with the tutorial for the solution of this problem. In this tutorial, you&#8217;ll see how to display the pop-up message in mouse clicked position using jQuery. When you click the mouse in any position of document, the pop-up message gets displayed with the mouse position around the middle part of the pop-up message.</p>
<p><span id="more-203"></span></p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/examples/popup-message/" target="_blank"><strong>Live Demo</strong></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://roshanbh.com.np/codes/popup-message.zip"><strong>Download Full Source Code</strong></a></p>
<h4>HTML code to display pop-up message on mouse clicked position</h4>
<pre class="prettyprint" style="overflow:auto ">&lt;div id="popuup_div" class="popup_msg"&gt;
   ....you can write the mssage here...
&lt;/div&gt;</pre>
<p style="text-align: justify;">As you can above, the element displaying pop-up message is defined with the id &#8220;<span style="color: #000080;">popup_div</span>&#8221; and class of this element is &#8220;<span style="color: #000080;">popup_msg</span>&#8220;. You can write your custom message inside that div.</p>
<h4>CSS code to display pop-up message on mouse clicked position</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.popup_msg{</span>
<span style="color: #333399;">position:absolute;
z-index:10;
width:172px;
height:102px;
text-align:center;
color:#FF0000;
font: 14px Verdana, Arial, Helvetica, sans-serif;
background:url(bg_image.gif) bottom right no-repeat;
display:none;</span>
<span style="color: #ff00ff;">}</span></pre>
<p style="text-align: justify;">The above CSS attribute is straightforward and you can change the attribute according to your requirement. But remember that, the <span style="color: #000080;">position</span> attribute should be set to <span style="color: #000080;">absolute</span> value and <span style="color: #000080;">z-index</span> should be greater than the other element&#8217;s z-index. Furthermore, the width and height attribute must be set according to the background image of pop-up message.</p>
<h4>JavaScript ( jQuery ) code for displaying pop-up message</h4>
<pre class="prettyprint" style="overflow:auto ">$(document).click(function(e)
{
  //getting height and width of the message box
  var height = $('#popuup_div').height();
  var width = $('#popuup_div').width();
  //calculating offset for displaying popup message
  leftVal=e.pageX-(width/2)+"px";
  topVal=e.pageY-(height/2)+"px";
  //show the popup message and hide with fading effect
  $('#popuup_div').css({left:leftVal,top:topVal}).show().fadeOut(1500);
});</pre>
<p style="text-align: justify;">As the above code is well document. I&#8217;m just going to give you the brief description. First of all, we took the height and width of the pop-up element. After that, we&#8217;ve calculated the <span style="color: #000080;">left</span> and <span style="color: #000080;">top</span> offset of element so that it gets displayed with the mouse position is around in it&#8217;s middle part. of the element With the last  line of jQuery code, pop-up message&#8217;s left and top position is set and displayed. This pop-up message gets hidden with fading effect with the <span style="color: #000080;">fadeOut()</span> function of jQuery.</p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/examples/popup-message/" target="_blank"><strong>Live Demo</strong></a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://roshanbh.com.np/codes/popup-message.zip"><strong>Download Full Source Code</strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=203&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/08/pop-up-message-mouse-clicked-position-jquery.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>State preserved bottom hanging message box using jQuery</title>
		<link>http://roshanbh.com.np/2008/07/state-preserved-bottom-hanging-message-box-using-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/07/state-preserved-bottom-hanging-message-box-using-jquery.html#comments</comments>
		<pubDate>Wed, 23 Jul 2008 11:45:53 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=169</guid>
		<description><![CDATA[Last time, I&#8217;ve made the top floating message box using jquery. And a lot of people has asked me how can I preserve the state of that message box so that when it is closed.It won&#8217;t be open to for some time interval. Today, I&#8217;ve come with state preserved bottom hanging message box. When you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fstate-preserved-bottom-hanging-message-box-using-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fstate-preserved-bottom-hanging-message-box-using-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Last time, I&#8217;ve made the top floating message box using jquery. And a lot of people has asked me how can I preserve the state of that message box so that when it is closed.It won&#8217;t be open to for some time interval. Today, I&#8217;ve come with state preserved bottom hanging message box. When you close the message box, it&#8217;s state is preserved in cookie created using JavScript so that this message box won&#8217;t show up for certain hours.</p>
<p><span id="more-169"></span></p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/examples/bottom-hanging-jquery" target="_blank"><strong>View Live Demo </strong></a></p>
<p style="text-align: justify;">I&#8217;m not going to post the HTML code, it is same the previous post of <a href="http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html">floating message box using jQuery</a>. You can refer to that article for HTML code.</p>
<h4>CSS code for state preserved hanging message</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">#message_box { </span>
<span style="color: #333399;">position: absolute;
left: 0px;
z-index: 10;
background:#ffc;
padding:5px;
border:1px solid #CCCCCC;
text-align:center;
width:99%;
display:none;
color:#0000FF;
font: bold 12px Verdana, Arial, Helvetica, sans-serif;</span>
<span style="color: #ff00ff;">}</span></pre>
<p style="text-align: justify;">The element with id &#8220;message_box&#8221; is made hidden first with it&#8217;s position set to &#8220;absolute&#8221; for making it hanging. Other attribute you can change according to your need.</p>
<h4>JavaScript Code for state preserved hanging message box</h4>
<p style="text-align: justify;">As this time, I&#8217;ve come up with the state preserved solution. I&#8217;ve used JavaScript for setting and getting value from cookie. I&#8217;ve used two functions getCookie()  directly taken from <a href="http://www.w3schools.com/JS/js_cookies.asp" target="_blank">w2school&#8217;s JavaScript cookie tutorial</a>.But I&#8217;ve modified the setCookie() functions where you can set the cookie expirty time in number of hours Here is that function,</p>
<pre class="prettyprint" style="overflow:auto">//function to set the cookie name, values and expiry time in hours
function setCookie(c_name,value,expireHours)
{
  var exhour=new Date(); //create the current date object
  exhour.setHours(exhour.getHours()+1); //setting hours
  document.cookie=c_name+ "=" +escape(value)+
  ((expireHours==null) ? "" : ";expires="+exhour.toGMTString());
}</pre>
<p style="text-align: justify;">Now, let&#8217;s dig through the jQuery code to provide the state preserved bottom hanging message box.</p>
<pre class="prettyprint" style="overflow:auto">//when the close button at right corner of the message box is clicked
$('#close_message').click(function()
{
  //the messagebox gets scrool down with top property and gets hidden with zero opacity
  $('#message_box').animate({ top:"-=15px",opacity:0 }, "slow");
   setCookie('show_message','no',1); //cookies is set to "no" value
});</pre>
<p style="text-align: justify;">As you can see above, when the cross icon is clicked the message box gets hidden and furtheremroe, it sets a cookie &#8220;show_message&#8221; with value &#8220;no&#8221; which expires in one hour. Now, look at the jquery code,</p>
<pre class="prettyprint" style="overflow:auto">if(getCookie('show_message')!='no')
{
  var pos=parseInt($(window).scrollTop())+parseInt($(window).height());
  $('#message_box').css("top",pos-26+"px");
  $('#message_box').show(); //display the message box

  //scroll the message box to the top offset of browser's scrool bar
  $(window).scroll(function()
  {
    var pos=parseInt($(window).scrollTop())+parseInt($(window).height());
    $('#message_box').animate({top:pos-26+"px" },{queue: false, duration: 500});
  });
}</pre>
<p style="text-align: justify;">As, you can see there is condition to show the message box and  code inside scroll event to execute. If the cookie is not set then the message box gets displayed and it will be shown to the bottom of the page according to the requirement.</p>
<p style="text-align: justify;"><a href="http://roshanbh.com.np/codes/bottom-hanging-jquery.zip" target="_blank"><strong>Download Full Source Code </strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=169&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/07/state-preserved-bottom-hanging-message-box-using-jquery.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Top Floating message box using jQuery</title>
		<link>http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html#comments</comments>
		<pubDate>Sun, 13 Jul 2008 09:29:55 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[message box]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=162</guid>
		<description><![CDATA[Last time, I&#8217;ve shown you how to create a alert box using jQuery. This time, I&#8217;ve come up with another tutorial to show you how to display floating message box in the top of  the browser using jQuery. The message box always get displayed at the top of the browser although you move across the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Ftop-floating-message-box-using-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Ftop-floating-message-box-using-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">Last time, I&#8217;ve shown you how to create a alert box using jQuery. This time, I&#8217;ve come up with another tutorial to show you how to display floating message box in the top of  the browser using jQuery. The message box always get displayed at the top of the browser although you move across the document with help of scroll bar. Now, let&#8217;s kick out this tutorial for creating floating message box using jQuery.</p>
<p><span id="more-162"></span></p>
<p style="text-align: justify; font-weight: bold;"><a href="http://roshanbh.com.np/examples/floating-message-jquery/" target="_blank">LIVE DEMO</a></p>
<h4>HTML code for floating message box using jQuery</h4>
<pre class="prettyprint" style="overflow:auto">&lt;div id="message_box"&gt;
    &lt;img id="close_message" style="float:right;cursor:pointer" src="12-em-cross.png" /&gt;
    The floating message goes here
&lt;/div&gt;

&lt;div&gt;
  ..............
  other content goes here
  ..................
&lt;/div&gt;
</pre>
<p style="text-align: justify;">The message box which is going to float in the top of the browser is inside the div with id &#8220;message-box&#8221; and this div is defined with the class &#8220;cornerbox&#8221;. And the small image with id &#8220;close_message&#8221; to close the message box and is displayed in the right hand side by setting the <span style="color: #333399;">float</span> attribute of CSS to <span style="color: #333399;">right</span> .</p>
<h4>CSS code for floating message box using jQuery</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">#message_box {</span>
<span style="color: #333399;">position: absolute;
top: 0; left: 0;
z-index: 10;
background:#ffc;
padding:5px;
border:1px solid #CCCCCC;
text-align:center;
font-weight:bold;
width:99%;</span>
<span style="color: #ff00ff;">}</span></pre>
<p style="text-align: justify;">You can see that CSS code for the floating message box is straightforward and you can change the color , size etc. according to your choice. But keep in mind that, &#8220;position&#8221; property must be absolute so that this message box doesn&#8217;t distract the other boxes and &#8220;z-index&#8221; must be set higher so that the it overlaps the other content of the web page.</p>
<h4>jQuery code for floating message box</h4>
<pre class="prettyprint" style="overflow:auto">&lt;script type="text/javascript" language="javascript" src="jquery-1.2.6.min.js"&gt;&lt;/script&gt;</pre>
<p style="text-align: justify;">You must notice that I&#8217;ve used jquery 1.2.6 in this example as dimension plugin of jquery is embedded in the this version of jQuery. If you use the lesser version of jQuery than 1.2.6 then must use the dimension plugin of jQuery to use this example.</p>
<pre class="prettyprint" style="overflow:auto">//scroll the message box to the top offset of browser's scrool bar
$(window).scroll(function()
{
  $('#message_box').animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});
});
</pre>
<p style="text-align: justify;">As you can when the window gets scrolled this function is called and the box gets moved as the &#8220;top&#8221; property of message box is set to different pixel using <a href="http://docs.jquery.com/Plugins/dimensions/scrollTop">scrollTop()</a> function, which had been the part dimension plugin of jQuery. This function return the scroll top offset of the matched element and in our example this return the scroll top offeset of the browser&#8217;s window. Another thing you must notice in the animate function that queue is set to false which makes the animation to skip the queue and begins running immediately otherwise the animation may stuck in the queue and looks ugly.</p>
<pre class="prettyprint" style="overflow:auto">//when the close button at right corner of the message box is clicked
$('#close_message').click(function()
{
  //the messagebox gets scrool down with top property and gets hidden with zero opacity
  $('#message_box').animate({ top:"+=15px",opacity:0 }, "slow");
});</pre>
<p style="text-align: justify;">It is the simple animation when the image with close sign is clicked, the message box slides down below and gets hidden because its opacity set to zero in the animation function.</p>
<p style="text-align: justify; font-weight: bold;"><a href="http://roshanbh.com.np/codes/floating-message-jquery.zip" target="_blank">DOWNLOAD FULL SOURCE CODE </a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=162&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/07/top-floating-message-box-using-jquery.html/feed</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Flashing Alert Message Box using JQuery</title>
		<link>http://roshanbh.com.np/2008/07/animated-alert-message-box-using-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/07/animated-alert-message-box-using-jquery.html#comments</comments>
		<pubDate>Wed, 02 Jul 2008 17:11:49 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[alertbox]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[messegeabox]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=126</guid>
		<description><![CDATA[As you can see in the poll running on this blog, jQuery is leading among the other JavaScript framework by a good margin. And, this blogger is also a great fan of jQuery.This time, I&#8217;ve come up with another tutorial of jquery. In this post I&#8217;ll show you how to make sliding and flashing alert [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fanimated-alert-message-box-using-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F07%2Fanimated-alert-message-box-using-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p style="text-align: justify;">As you can see in the poll running on this blog, jQuery is leading among the other JavaScript framework by a good margin. And, this blogger is also a great fan of jQuery.This time, I&#8217;ve come up with another tutorial of jquery. In this post I&#8217;ll show you how to make sliding and flashing alert box in top left corner of the browser using jQuery. This alert box gets displayed with animation when the page is loaded for the first time.</p>
<p><span id="more-126"></span></p>
<p><a href="http://roshanbh.com.np/examples/alert-box/" target="_blank"><strong>Live Demo</strong></a></p>
<p style="text-align: justify;">Let&#8217;s start looking at the HTML, CSS and JavaScript Code in jquery to make the animated alerting message box using jQuery.</p>
<h4>HTML code for Flashing Alert Message using jQuery</h4>
<pre class="prettyprint" style="overflow:auto ">&lt;div id="object" class="message"&gt;
  &lt;img id="close_message" style="float:right;cursor:pointer" src="12-em-cross.png" /&gt;
  &lt;strong&gt;Massive Offer &lt;/strong&gt;
  &lt;p&gt;The detail of this offer goes here dude just Grab this offer !!!!!!! &lt;/p&gt;
&lt;/div&gt;</pre>
<p style="text-align: justify;">As you the message box which I want to display is inside the &#8220;div&#8221; element with id &#8220;object&#8221;. And there is an image inside of this box with id &#8220;close_window&#8221;, when this image is clicked the message box gets vanished with fading effect.</p>
<h4>CSS code for Flashing Alert Message Box using jQuery</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.message{</span>
<span style="color: #333399;">border:1px solid #CCCCCC;
position:absolute;
width:150px;
border:1px solid #c93;
background:#ffc;
padding:5px;
left:0px;
top : -170px;</span>
<span style="color: #ff00ff;">}</span></pre>
<p>As you know, I&#8217;m very poor in selecting good colors, please forgive me for the bad design of the alert box.</p>
<p style="text-align: justify;">Above is the class which I&#8217;ve used for flashing message box. The position property must be &#8220;absolute&#8221; and the top property should be choosen such a way that the message box gets hidden in the top part of the browser. The other part property of CSS is straightforward you can change them according to your need.</p>
<h4>JavaScript code in jQuery for Flashing Alert Message Box</h4>
<pre class="prettyprint" style="overflow:auto ">$(document).ready(function()
{
  //first slide down and blink the message box
  $("#object").animate({
  top: "0px"
  }, 2000 ).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

  //close the message box when cross red image is clicked
  $("#close_message").click(function()
  {
     $("#object").fadeOut("slow");
  });
});</pre>
<p style="text-align: justify;">As you know, we&#8217;ve placed the message box in the top of the browser in such a way that it is not visible in the browsers. Now, the above jQuery code is used this message box to get slide down and gets flashed in the browser. For this, I&#8217;ve used animate() and fadeOut() and fadeIn() functions of jQuery.</p>
<p>And, when the close image of the message box is clicked, the alert box gets vanished with the fading effect.</p>
<p><a href="http://roshanbh.com.np/codes/alert-box.zip" target="_blank"><strong>Download Full Source Code </strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=126&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/07/animated-alert-message-box-using-jquery.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Block Shuffling effect using jquery</title>
		<link>http://roshanbh.com.np/2008/06/block-shuffle-effect-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/06/block-shuffle-effect-jquery.html#comments</comments>
		<pubDate>Sun, 08 Jun 2008 05:14:54 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[animation]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=122</guid>
		<description><![CDATA[Last time, I showed you how to navigate the content in various effect using jQuery. In this post, I&#8217;ll show you how can you generate the shuffle effect i.e one block moves under another block with sliding from the left. LIVE DEMO Now let&#8217;s look at the various code to perform this task. HTML and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fblock-shuffle-effect-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Fblock-shuffle-effect-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Last time, I showed you how to <a href="http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html ">navigate the content in various effect</a> using jQuery. In this post, I&#8217;ll show you how can you generate the shuffle effect i.e one block moves under another block with sliding from the left.</p>
<p><span id="more-122"></span></p>
<p style="text-align: justify;"><strong><a href="http://roshanbh.com.np/examples/block-shuffle" target="_blank">LIVE DEMO</a></strong></p>
<p style="text-align: justify;">Now let&#8217;s look at the various code to perform this task.</p>
<h4>HTML and CSS code for shuffling the block</h4>
<p style="text-align: justify;">This code is same as the the one I&#8217;ve shown you in the <a href="http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html" target="_blank">content navigation effect using jquery</a> post. <a href="http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html" target="_blank">Please refer to that post</a> to view the HTML and CSS code for detail. Note that, each link&#8217;s &#8220;href&#8221; attribute is pointing to the &#8220;id&#8221; element of the block.</p>
<h4>JavaScript code in jQuery to shuffle the block</h4>
<pre class="prettyprint" style="overflow:auto">//when the anchor is clicked
$("a.linkclass").click(function()
{
   //check weather the visible block and clicked link's block is same or different
   if($(this).attr("href")!="#"+$(".msg_body:visible").attr("id"))
   {
      //reduces the z-index and margin of left side increased and decreased by 400px and hide
      $(".msg_body:visible").css("z-index","0").animate({marginLeft: "-=400px"},"500").animate({marginLeft: "+=400px"},"500").hide("1");
     //increase the z-index of the new visible block
     $($(this).attr("href")).css("z-index","10").fadeIn(400);
   }
}</pre>
<p style="text-align: justify;">When the anchor with the &#8220;linkclass&#8221; is clicked, first of all it is check that weather the clicked anchor&#8217;s link is same as the visible block. If it is the same then the animation doesn&#8217;t take place. When these are different, then the visible block&#8217;s &#8220;z-index&#8221; is decreased to zero and it gets slides to the left and then into right by using altering the value in the &#8220;margin-left&#8221; property. And, finally this block gets hidden. In the meanwhile, block whose name in the &#8220;href&#8221; attribute of the clicked anchor gets visible with fade in effect and &#8220;z-index&#8221; of this block is set to &#8220;10&#8243; so that it overlaps the slided block.</p>
<p style="text-align: justify;"><strong><a href="http://roshanbh.com.np/codes/block-shuffle.zip" target="_blank">Download Full Source Code</a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=122&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/06/block-shuffle-effect-jquery.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Making accordion menu using jquery</title>
		<link>http://roshanbh.com.np/2008/06/accordion-menu-using-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/06/accordion-menu-using-jquery.html#comments</comments>
		<pubDate>Sun, 01 Jun 2008 09:57:55 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=115</guid>
		<description><![CDATA[Last time, I&#8217;ve shown how to create accordion using jquery. But, In this post I&#8217;ll show you how can you create fancy accordion menu using jQuery. In this post, you&#8217;ll see two examples of accordion. First menu&#8217;s visibility get&#8217;s toggled on clicking on the header while the another menu&#8217;s visibility get&#8217;s toogled when mouse is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Faccordion-menu-using-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F06%2Faccordion-menu-using-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Last time, I&#8217;ve shown how to create <a href="http://roshanbh.com.np/2008/03/make-accordion-using-jquery.html">accordion using jquery</a>. But, In this post I&#8217;ll show you how can you create fancy accordion menu using jQuery. In this post, you&#8217;ll see two examples of accordion. First menu&#8217;s visibility get&#8217;s toggled on clicking on the header while the another menu&#8217;s visibility get&#8217;s toogled when mouse is moved over it.</p>
<p><span id="more-115"></span></p>
<h4>Live Demo of accordion menu using jQuery</h4>
<p><iframe src="http://roshanbh.com.np/examples/accordion-menu" width="459" height="200" scrolling="no" frameborder="0"></iframe></p>
<h4>HTML structure for  accordion menu using jQuery</h4>
<pre class="prettyprint" style="overflow:auto">&lt;div id="firstpane" class="menu_list"&gt;
  &lt;p class="menu_head"&gt;Header-1&lt;/p&gt;
    &lt;div class="menu_body"&gt;
	&lt;a href="#"&gt;Link-1&lt;/a&gt;
    &lt;/div&gt;
  &lt;p class="menu_head"&gt;Header-2&lt;/p&gt;
    &lt;div class="menu_body"&gt;
	&lt;a href="#"&gt;Link-1&lt;/a&gt;
    &lt;/div&gt;
  &lt;p class="menu_head"&gt;Header-3&lt;/p&gt;
    &lt;div class="menu_body"&gt;
        &lt;a href="#"&gt;Link-1&lt;/a&gt;
   &lt;/div&gt;
&lt;/div&gt;</pre>
<p align="justify">As you can see the structure, the elements of the menu are inside the div with class &#8220;menu_list&#8221;. And each blocks of menu contains the header with class &#8220;menu_head&#8221; and div with class &#8220;menu_body&#8221;. Note that, there is another pane with the id &#8220;secondpane&#8221; whose code is similar as above and not posted above.</p>
<h4>CSS code  for accordion menu using jQuery</h4>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.menu_list {</span>
	<span style="color: #000080;">width: 150px;</span>
<span style="color: #ff00ff;">}
.menu_head {</span>
	<span style="color: #333399;">padding: 5px 10px;
	cursor: pointer;
	position: relative;
	margin:1px;
       font-weight:bold;
       background: #eef4d3 url(left.png) center right no-repeat;</span>
<span style="color: #ff00ff;">}
.menu_body {</span>
	<span style="color: #333399;">display:none;</span>
<span style="color: #ff00ff;">}
.menu_body a {</span>
 <span style="color: #333399;"> display:block;
  color:#006699;
  background-color:#EFEFEF;
  padding-left:10px;
  font-weight:bold;
  text-decoration:none;</span>
<span style="color: #ff00ff;">}
.menu_body a:hover {</span>
  <span style="color: #333399;">color: #000000;
  text-decoration:underline;</span>
<span style="color: #ff00ff;">}</span></pre>
<p align="justify">I&#8217;m not a good color chooser so please forgive me for the color combinations. Above CSS code is straight forward and you can change is according to your need. Note that, the display property in &#8220;menu_body&#8221; is set to &#8220;hidden&#8221; so that the menu links are hidden when the page is loaded. Furthermore, the display property in the link inside &#8220;menu_body&#8221; class is set to &#8220;block&#8221; so that each menu appears in new line. You can see a image in the &#8220;menu_head&#8221; class, this is the image which gets changes with the visibility of the menu item in each menu&#8217;s head.</p>
<p align="justify">I&#8217;ve used the images from <a href="http://sweetie.sublink.ca/">sweetie icon pack</a>, you can download the other <a rel="nofollow" href="http://sweetie.sublink.ca/">beautiful icon from the their website</a>.</p>
<h4>Javascript Code using jQuery</h4>
<p align="justify">Now finally look at the JavaScript code to accomplish this, first of we need to import the jQuery library</p>
<pre class="prettyprint" style="overflow:auto">&lt;script type="text/javascript" language="javascript" src="jquery.js"&gt;&lt;/script&gt;</pre>
<p align="justify">And, then we need to write few lines of simple code in jQuery to do this, let&#8217;s look at the jquery code of the first accordion menu whose visibility gets toggled on the mouse click event on each header,</p>
<pre class="prettyprint" style="overflow:auto">//slides the element with class "menu_body" when paragraph with class "menu_head" is clicked
$("#firstpane p.menu_head").click(function()
{
    $(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
    $(this).siblings().css({backgroundImage:"url(left.png)"});
});</pre>
<p align="justify">When the paragraph with class &#8220;menu_head&#8221; inside the element with the id &#8220;firstpane&#8221; gets clicked, the background image of it changed to down arrow. And then, next div with class &#8220;menu_body&#8221; gets slided in toggling it&#8217;s visibility. Furthermore, the other sibling&#8217;s div with class &#8220;menu_body&#8221; gets slided up. And then, the background image of the other sibling&#8217;s of &#8220;p&#8221; is changed to left arrow. Now look at the code of the accordion menu under mouse over effect.</p>
<pre class="prettyprint" style="overflow:auto">//slides the element with class "menu_body" when mouse is over the paragraph
$("#secondpane p.menu_head").mouseover(function()
{
   $(this).css({backgroundImage:"url(down.png)"}).next("div.menu_body").slideDown(500).siblings("div.menu_body").slideUp("slow");
   $(this).siblings().css({backgroundImage:"url(left.png)"});
});</pre>
<p align="justify">This code is preety similar to the above code but the difference is only that this accordion menu works on the mouse over effect whereas the above accordion menu works on the mouse click event.</p>
<p><strong><a href="http://roshanbh.com.np/codes/accordion-menu.zip" target="_blank">Download Source Code</a></strong></p>
<p>If you want to learn more about jQuery then you can check the following books and buy them.I really recommend the book &#8220;<strong>jQuery in Action</strong>&#8221; for starting your way for jQuery.</p>
<pre><a rel="nofollow" href="http://affiliate.buy.com/gateway.aspx?adid=17662&amp;aid=10387773&amp;pid=3141609&amp;sURL=http%3A%2F%2Fwww.buy.com%2Fprod%2Flearning-jquery-better-interaction-design-and-web-development-with%2Fq%2Floc%2F106%2F204995923.html&amp;cjsku=204995923" target="_top"><img src="http://ak.buy.com/db_assets/prod_images/923/204995923.jpg" border="0" alt="Learning Jquery: Better Interaction Design and Web Development with Simple JavaScript Techniques" /></a>
<img src="http://www.afcyhf.com/image-3141609-10387773" border="0" alt="" width="1" height="1" />

<a rel="nofollow" href="http://affiliate.buy.com/gateway.aspx?adid=17662&amp;aid=10387773&amp;pid=3141609&amp;sURL=http%3A%2F%2Fwww.buy.com%2Fprod%2Fjquery-in-action%2Fq%2Floc%2F106%2F205775038.html&amp;cjsku=205775038" target="_top"><img src="http://ak.buy.com/db_assets/prod_images/038/205775038.jpg" border="0" alt="Jquery in Action" /></a>
<img src="http://www.afcyhf.com/image-3141609-10387773" border="0" alt="" width="1" height="1" /></pre>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=115&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/06/accordion-menu-using-jquery.html/feed</wfw:commentRss>
		<slash:comments>202</slash:comments>
		</item>
		<item>
		<title>Animated content navigation effect using jquery</title>
		<link>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html#comments</comments>
		<pubDate>Thu, 08 May 2008 06:58:20 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/?p=104</guid>
		<description><![CDATA[I always get bored with the same stuffs. And, I see same kind of content navigation to the different websites. Click a link, let&#8217;s the whole web page gets loaded and new page gets displayed. It would be better to show another content in the same page with few animation without loading the whole page. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F05%2Fanimated-content-navigation-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F05%2Fanimated-content-navigation-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">I always get bored with the same stuffs. And, I see same kind of content navigation to the different websites. Click a link, let&#8217;s the whole web page gets loaded and new page gets displayed. It would be better to show another content in the same page with few animation without loading the whole page.</p>
<p><span id="more-104"></span></p>
<p align="justify">In this post, I&#8217;ll show you how to make various animation to the content using jQuery. First of let&#8217;s start looking at the HTML and CSS code,</p>
<p align="justify"><strong>HTML Code for animated content navigation </strong></p>
<pre class="prettyprint" style="overflow:auto ">&lt;a href="#home" class="linkclass" &gt;Home&lt;/a&gt;
&lt;a href="#about_us" class="linkclass" &gt;About Us&lt;/a&gt;
&lt;a href="#service" class="linkclass" &gt;Services&lt;/a&gt;
&lt;a href="#contact_us" class="linkclass" &gt;Contact Us&lt;/a&gt;

&lt;div class="container"&gt;
    &lt;div id="home" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="about_us" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="service" class="msg_body"&gt; content goes here &lt;/div&gt;
    &lt;div id="contact_us" class="msg_body"&gt;  content goes here &lt;/div&gt;
&lt;/div&gt;</pre>
<p align="justify">As you can see above, the &#8220;href&#8221; attribute of the anchor tag is pointing to the id of the &#8220;div&#8221;. &#8220;Home&#8221; anchor tag is pointing to &#8220;#home&#8221;. In jquery, id of a element is represented by adding &#8220;#&#8221; prefix to the id of that element.</p>
<p align="justify"><strong>CSS code for animated content navigation</strong></p>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.container
{</span>
  <span style="color: #333399;"> width:312px;
   margin-top:20px;</span>
<span style="color: #ff00ff;">}
.msg_body
{</span>
 <span style="color: #333399;"> border:1px solid #CCCCCC;
  padding: 5px;
  width: 300px;
  background-color:#F4F4F8;
  text-align:justify;
  position:absolute;</span>
<span style="color: #ff00ff;">}
.linkclass
{</span>
<span style="color: #333399;">  font-weight:bold;
  color:#006699;</span>
<span style="color: #ff00ff;">}</span></pre>
<p align="justify">Above CSS code is pretty straight forward and you can change it according to your need. Note that, there is position attribute to &#8220;absolute&#8221; in the &#8220;msg_body&#8221; class. Now let&#8217;s look at various the javaScript code in jQuery to make the various animated content navigation</p>
<p align="justify"><strong>Faded content navigation</strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto"> //hide the all div except first one
$('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
  $('.msg_body').fadeOut("slow");
  $($(this).attr("href")).fadeIn("slow");
});</pre>
<p align="justify">In the first line of javaScript code, all the element with class &#8220;msg_body&#8221; is made hidden except the first element with same class. And when the anchor with class &#8220;linkclass&#8221; is clicked, the element with class &#8220;msg_body&#8221; gets faded out which is being displayed in browser. And, the element with the id value in the &#8220;href&#8221; attribute of the clicked anchor tag, get displayed in browser with fading effect.</p>
<p align="justify"><strong>Shutter like content navigation effect<br />
</strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index1.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto">//hide the all div except first one
$('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
   $('.msg_body').hide("fast");
   $($(this).attr("href")).show("slow");
});</pre>
<p align="justify">The code is same as the above code but here &#8220;hide()&#8221; and &#8220;show()&#8221; function of jQuery is used to hide and display the content in different manner.</p>
<p align="justify"><strong>Sliding Content Navigation Effect </strong></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/content-move/index3.html" target="_blank">View Live Demo </a></strong></p>
<pre class="prettyprint" style="overflow:auto"> //hide the all div except first one
 $('.msg_body:not(:first)').hide();
//when the anchor is clicked content gets faded
$("a.linkclass").click(function()
{
   $('.msg_body').slideUp("slow");
   $($(this).attr("href")).slideDown("slow"););
});</pre>
<p align="justify">This is another content navigation effect with sliding manner. &#8220;slideUp()&#8221; and &#8220;slideDown()&#8221; functions of jQuery is used to display this kind of effect.</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/content-move.zip">Download full source code</a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=104&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/05/animated-content-navigation-jquery.html/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Ajax login validation system in PHP using jQuery</title>
		<link>http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html#comments</comments>
		<pubDate>Thu, 24 Apr 2008 10:57:04 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html</guid>
		<description><![CDATA[Last time, I&#8217;ve showed you how to check user availability in Ajax using jQuery&#8217;s fading effect. But I&#8217;ve just shown the example without connecting the database and some people have faced problem with database connecting solution of that problem.In this post, I&#8217;ll show you how to use Ajax login system in php using jQuery and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fajax-login-validation-php-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fajax-login-validation-php-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Last time, I&#8217;ve showed you how to <a href="http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html">check user availability in Ajax using jQuery&#8217;s fading effect</a>. But I&#8217;ve just shown the example without connecting the database and some people have faced problem with database connecting solution of that problem.In this post, I&#8217;ll show you how to use Ajax login system in php using jQuery and some animation as well.</p>
<p><span id="more-98"></span></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/ajax-login-php" target="_blank">View Demo </a></strong></p>
<p align="justify">In this example, first of all we&#8217;ll validate the user login detail from ajax showing the messages with some animation. If authenticated, the user will be redirected to the secure page &#8220;secure.php&#8221;. If you&#8217;ll try to directly access &#8220;secure.php&#8221;, you can&#8217;t do that.</p>
<p align="justify">Now let&#8217;s look at the code how to do this,</p>
<p align="justify"><strong>HTML Code</strong></p>
<pre class="prettyprint" style="overflow: auto">&lt; form method="post" action="" id="login_form" /&gt;
  &lt; input name="username" type="text" id="username" value="" maxlength="20" /&gt;
  &lt; input name="password" type="password" id="password" value="" maxlength="20" /&gt;
  &lt; input name="Submit" type="submit" id="submit" value="Login" /&gt;
&lt; /form &gt;</pre>
<p align="justify">As you can see in html code, we&#8217;ve created the form with id &#8220;login_form&#8221;.</p>
<p align="justify">And furthermore, the CSS code is same as the one available in the pervious post of checking user availability in ajax and php.</p>
<h4>JavaScript Code for Ajax Login validation system in PHP</h4>
<p align="justify">First of all we need to use the jQuery library in our code,</p>
<pre class="prettyprint" style="overflow: auto">&lt; script src="jquery.js" type="text/javascript" language="javascript"&gt;&lt;/script &gt;</pre>
<p align="justify">Now let&#8217;s look at the code in javaScript to call ajax and show the animated message with fading effects.</p>
<pre class="prettyprint" style="overflow: auto">$("#login_form").submit(function()
{
	//remove all the class add the messagebox classes and start fading
	$("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000);
	//check the username exists or not from ajax
	$.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data)
        {
	  if(data=='yes') //if correct login detail
	  {
		$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
		{
 		  //add message and change the class of the box and start fading
		  $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1,
                  function()
		  {
  	  	     //redirect to secure page
		     document.location='secure.php';
		  });
		});
	  }
	  else
	  {
	  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
		{
		  //add message and change the class of the box and start fading
		  $(this).html('Your login detail sucks...').addClass('messageboxerror').fadeTo(900,1);
		});
          }
       });
       return false;//not to post the  form physically
});</pre>
<p align="justify">As you can see above this code is preety much similar to the previous post of <a href="http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html">checking username availability in ajax and php</a> and you can see the explanation of the above code from that post. But in above code, where the user is validated, he&#8217;ll be logged into the &#8220;secure.php&#8221; using &#8220;document.location&#8221; in JavaScript.</p>
<pre class="prettyprint" style="overflow: auto">$("#password").blur(function()
{
	$("#login_form").trigger('submit');
});</pre>
<p align="justify">Well, as you can see above javaScript&#8217;s code, when focus is moved away from the password it also call the for sumit action. Basically whenever you hit tab button in password field, it starts validating the user detail using ajax.</p>
<h4>PHP Code for Ajax Login validation system</h4>
<p align="justify">First of all lets&#8217;s look at the code of the &#8220;ajax_login.php&#8221;.</p>
<pre class="prettyprint" style="overflow: auto">//get the posted values
$user_name=htmlspecialchars($_POST['user_name'],ENT_QUOTES);
$pass=md5($_POST['password']); 

//now validating the username and password
$sql="SELECT user_name, password FROM tbl_user WHERE user_name='".$user_name."'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result); 

//if username exists
if(mysql_num_rows($result)&gt;0)
{
	//compare the password
	if(strcmp($row['password'],$pass)==0)
	{
		echo "yes";
		//now set the session from here if needed
		$_SESSION['u_name']=$user_name;
	}
	else
		echo "no";
}
else
	echo "no"; //Invalid Login</pre>
<p align="justify">As you can see above, the user login detial is validated from the database. If the user login detail doesn&#8217;t exists, it just returns the &#8220;no&#8221; values and if the user login detial does exists the it just return &#8220;yes&#8221; values with setting username in session variable.</p>
<p align="justify">Finally,  let&#8217;s look at the code of <strong>secure.php</strong></p>
<pre class="prettyprint" style="overflow: auto">if(empty($_SESSION['u_name']))
  header("Location:index.html");
//if logout then destroy the session and redirect the user
if(isset($_GET['logout']))
{
  session_destroy();
  header("Location:index.html");
}
echo " &lt;a href='secure.php?logout'&gt;&lt;b&gt;Logout&lt;b&gt;&lt;/a&gt; ";
echo " &lt;div align='center'&gt;You Are inside secured Page&lt;/a&gt; ";</pre>
<p align="justify">As you can see above the code of &#8220;secure.php&#8221; is simpleforward. If the user is not authenticated by session then he&#8217;ll be redirected to &#8220;index.html&#8221;. And there is link for &#8220;logout&#8221; in this page form where user can destroy the seession.</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/ajax-login-php.zip" target="_blank">Download Full Source Code</a> </strong></p>
<p align="justify"><strong>Implementation Guide:</strong></p>
<p align="justify">To implement this code, dump the tbl_user &#8220;table&#8221; available in the zip file to your database and configure the database connection in &#8220;ajax_login.php&#8221;.</p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=98&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html/feed</wfw:commentRss>
		<slash:comments>156</slash:comments>
		</item>
		<item>
		<title>Textbox to accept only numbers (digits) using jquery</title>
		<link>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html</link>
		<comments>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html#comments</comments>
		<pubDate>Wed, 16 Apr 2008 17:33:41 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[textbox]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html</guid>
		<description><![CDATA[Few days back, my friend Parleen asked me how can we make a textbox which just accepts only numbers specially digits only. And, for his I come up with this solution of textbox which only accepts digits, and if you try to enter any alpha bates in it then it displays the error message with [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Ftextbox-accept-only-numbers-digits.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Ftextbox-accept-only-numbers-digits.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p align="justify">Few days back, my friend Parleen asked me how can we make a textbox which just accepts only numbers specially digits only. And, for his I come up with this solution of textbox which only accepts digits, and if you try to enter any alpha bates in it then it displays the error message with animation.</p>
<p><span id="more-88"></span></p>
<p align="justify"><strong><a href="http://roshanbh.com.np/examples/accept-only-digit/" target="_blank">View Demo </a></strong></p>
<p align="justify"><strong>HTML Code </strong></p>
<pre class="prettyprint" style="overflow: auto">&lt;input type="text" name="quantity" id="quantity" /&gt; &lt;span id="errmsg"&gt;&lt;/span&gt;</pre>
<p align="justify">As you can see above, I&#8217;ve given the name and id of textbox to &#8220;quantity&#8221; in this example.This is the textbox which only accepts numbers (digits only). You can see &#8220;span&#8221; after textbox which is used to display the error message with fading effect using jQuery.</p>
<p align="justify"><strong>Javascript Code </strong></p>
<p align="justify">First of all, we need to use jQuery library as we&#8217;re using the jquery&#8217;s function to accept only digits.</p>
<pre class="prettyprint" style="overflow: auto">&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;</pre>
<p align="justify">Now le&#8217;ts write the code in JavaScript using jQuery to accept only digits in textbox and displaying error with animation.</p>
<pre class="prettyprint" style="overflow: auto">//when key is pressed in the textbox$("#quantity").keypress(function (e)
{
  //if the letter is not digit then display error and don't type anything
  if( e.which!=8 &amp;&amp; e.which!=0 &amp;&amp; (e.which&lt;48 || e.which&gt;57))
  {
    //display error message
    $("#errmsg").html("Digits Only").show().fadeOut("slow");
    return false;
  }
});</pre>
<p align="justify">When the key is pressed, we&#8217;re using the key&#8217;s ASCII value to check which button is pressed. In first expression, delete, tab or backspace button is is checked and &#8220;8&#8243; is the ASCII values of the Back-space. Digits are checked in the second expression. &#8220;48&#8243; is the ASCII values of &#8220;0&#8243; and &#8220;57&#8243; is the ASCII values of  &#8220;9&#8243;. The the ASCII values of the other digits lies between &#8220;48&#8243; to &#8220;57&#8243;. And, if the key pressed values doesn&#8217;t lies withing these range, then we are displaying the error message with jQuery&#8217;s fading effect.</p>
<p align="justify">And, the &#8220;return false&#8221; statement means that this functions returns false values which means not to type anything on the text box.</p>
<p align="justify"><strong><a href="http://roshanbh.com.np/codes/accept-only-digit.zip" target="_blank">Download Full Source Code</a> </strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=88&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/textbox-accept-only-numbers-digits.html/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>Blink and bounce effect on image or object using jquery</title>
		<link>http://roshanbh.com.np/2008/04/blink-bounce-effect-image-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/04/blink-bounce-effect-image-jquery.html#comments</comments>
		<pubDate>Fri, 11 Apr 2008 16:56:51 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tips and technique]]></category>
		<category><![CDATA[blink]]></category>
		<category><![CDATA[bounce]]></category>
		<category><![CDATA[jqueyr effects]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/blink-bounce-effect-image-jquery.html</guid>
		<description><![CDATA[Yesterday, Sushil asked me how can we bounce and blink an image or div using jQuery.In this post, I&#8221;ll show you how you can add bounce or blink effect to an image or div using jQuery. Live Demo First of all, let&#8217;s begin with the html code to add blink and bounce effect to your [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fblink-bounce-effect-image-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fblink-bounce-effect-image-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<style type="text/css"> <!-- .style1 {color: #FF00FF} .style2 {color: #003399} .style3 { 	color: #0066CC; 	font-weight: bold; } .style4 { 	color: #0066FF; 	font-weight: bold; } --> </style>
<p align="justify">Yesterday, Sushil asked me how can we bounce and blink an image or div using jQuery.In this post, I&#8221;ll show you how you can add bounce or blink effect to an image or div using jQuery.</p>
<p><span id="more-84"></span><a href="http://roshanbh.com.np/examples/blink-bounce/" title="blink bounce effect jquery" target="_blank"><strong>Live Demo</strong></a></p>
<p align="justify">First of all, let&#8217;s begin with the html code to add blink and bounce effect to your object using jQuery.</p>
<p><strong>  HTML Code:</strong></p>
<pre class="prettyprint" style="overflow: auto">&lt;div id="object" class="message"&gt; lorem ipsum dolor sit amet, consectetuer adipiscing elit orem ipsum dolor sit amet, consectetuer adipiscing elit &lt;/div&gt;</pre>
<p align="justify">Here the object which is needed to be animated is defined with the class&#8221;message&#8221; and with id &#8220;object&#8221;. Remember that, you can also put image in that &#8220;div&#8221; to bounce or blink.</p>
<p><strong>Css Code:</strong></p>
<pre style="border: 1px solid #888888; padding: 2px">
<span class="style1">.message{</span>
<span class="style2">border:1px solid #CCCCCC;
padding: 5px;
width: 150px;
background-color:#F4F4F8;
text-align:justify;
position:absolute;
top:50px;</span>
<span class="style1">}</span></pre>
<p align="justify">You can see the attributes of the &#8220;message&#8221; class in css. You can change the above attributes as your need but remember one thing that the position property should be &#8220;absolute&#8221;. If you put it &#8220;relative&#8221;, the other object around the animated &#8220;div&#8221; or &#8220;image&#8221; starts get moved.</p>
<p><strong>Javascript Code: </strong></p>
<p class="style3">For blinking out the Object</p>
<pre class="prettyprint" style="overflow: auto">//hide the object with blink effect
$("#blink_out").click(function()
{
  $("#object").fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100);
});</pre>
<p align="justify">As you can see above code, it is straightforward. When an element with id &#8220;blink_out&#8221; gets clicked, the element with id &#8220;object&#8221; gets animated  with &#8220;fade out&#8221; and &#8220;fade in&#8221; effect of jQuery in alternative manner.</p>
<p class="style4">For blinking in the Object</p>
<pre class="prettyprint" style="overflow: auto">//show the object with blink effect
$("#blink_in").click(function()
{
  $("#object").fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);
});</pre>
<p align="justify">As you can see this code is same as the above code but altered the way the &#8220;image&#8221; or &#8220;div&#8221; gets faded.</p>
<p class="style4">For bouncing the Object</p>
<pre class="prettyprint" style="overflow: auto">//bounce an object
$("#bounce").click(function()
{
  $("#object").fadeIn(100).animate({top:"-=20px"},100).animate({top:"+=20px"},100).animate({top:"-=20px"},100)
.animate({top:"+=20px"},100).animate({top:"-=20px"},100).animate({top:"+=20px"},100);
});</pre>
<p>In the above code, we&#8217;ve used jquery&#8217;s animate() function to bounce an &#8220;image&#8221; or &#8220;div&#8221;. The &#8220;top&#8221; attribute of the object is toggled to show the bouncing effect on the object.</p>
<p><a href="http://roshanbh.com.np/codes/blink-bounce.zip" target="_blank"><strong>Download full source code </strong></a></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=84&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/blink-bounce-effect-image-jquery.html/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>check username availability in ajax and php using jquery&#8217;s fading effect</title>
		<link>http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html</link>
		<comments>http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html#comments</comments>
		<pubDate>Sat, 05 Apr 2008 16:53:45 +0000</pubDate>
		<dc:creator>Roshan</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[username]]></category>
		<category><![CDATA[username availability]]></category>

		<guid isPermaLink="false">http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html</guid>
		<description><![CDATA[In this post,I&#8217;ll show you how to make a fancy username availability checking in ajax and php using jquery.When, you check the the username avaiability a fancy message box will show you the message with a little bit of animation. If you are looking for such kind of effect for checking username availability, then this [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float:right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fcheck-username-available-ajax-php-jquery.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Froshanbh.com.np%2F2008%2F04%2Fcheck-username-available-ajax-php-jquery.html&amp;source=roshanbh&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post,I&#8217;ll show you how to make a fancy username availability checking in ajax and php using jquery.When, you check the the username avaiability a fancy message box will show you the message with a little bit of animation. If you are looking for such kind of effect for checking username availability, then this might be right post for you.<br />
<span id="more-82"></span></p>
<p><a href="http://roshanbh.com.np/examples/username-available/" target="_blank"><strong><br />
View Live Demo</strong></a></p>
<p align="justify">Now let&#8217;s check it how to do check the username avaiability in ajax and php using jQuery.</p>
<p align="justify"><strong>Html Code :</strong></p>
<pre class="prettyprint" style="overflow: auto">&lt;div &gt;
 User Name : &lt;input name="username" type="text" id="username" value="" maxlength="15" /&gt;
 &lt;span id="msgbox" style="display:none"&gt;&lt;/span&gt;
&lt;/div&gt;</pre>
<p align="justify">As you can see the above the &#8220;span&#8221; with id &#8220;msgbox&#8221; will show you the username availability message from ajax.</p>
<p align="justify"><strong>Css code :</strong></p>
<pre style="border: 1px solid #888888; padding: 2px"><span style="color: #ff00ff;">.messagebox{</span>
<span style="color: #333399;"> position:absolute;
 width:100px;
 margin-left:30px;
 border:1px solid #c93;
 background:#ffc;
 padding:3px;</span>
<span style="color: #ff00ff;">}</span>
<span style="color: #ff00ff;">.messageboxok{</span>
<span style="color: #333399;"> position:absolute;
 width:auto;
 margin-left:30px;
 border:1px solid #349534;
 background:#C9FFCA;
 padding:3px;
 font-weight:bold;
 color:#008000;</span>
<span style="color: #ff00ff;">}</span>
<span style="color: #ff00ff;">.messageboxerror{</span>
<span style="color: #333399;"> position:absolute;
 width:auto;
 margin-left:30px;
 border:1px solid #CC0000;
 background:#F7CBCA;
 padding:3px;
 font-weight:bold;
 color:#CC0000;</span>
<span style="color: #ff00ff;">}</span></pre>
<p align="justify">I&#8217;ve defined three different class for three type of different message class &#8220;messagebox&#8221; for &#8220;checking&#8230;.&#8221; message, &#8220;messageboxok&#8221; and &#8220;messageboxerror&#8221; class for displaying username available and not available messages.</p>
<p align="justify">As you know you can change the attriubutes of the css of the above code but keep in mind that &#8220;position&#8221; property should be &#8220;absolute&#8221;.</p>
<p align="justify"><strong>Javascript code :</strong></p>
<p align="justify">First of  all, the jQuery library is used,</p>
<pre class="prettyprint" style="overflow: auto">&lt;script src="jquery.js" type="text/javascript" language="javascript"&gt;&lt;/script&gt;</pre>
<p align="justify">And when the focus is moved from the textbox of username the following function is called which call &#8220;user_availability.php&#8221; through ajax and display the appropriate message with fading effect.</p>
<pre class="prettyprint" style="overflow: auto">$("#username").blur(function()
{
 //remove all the class add the messagebox classes and start fading
 $("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");
 //check the username exists or not from ajax
 $.post("user_availability.php",{ user_name:$(this).val() } ,function(data)
 {
  if(data=='no') //if username not avaiable
  {
   $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
   {
    //add message and change the class of the box and start fading
    $(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);
   });
  }
  else
  {
   $("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
   {
    //add message and change the class of the box and start fading
    $(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);
   });
  }
 });
});</pre>
<p align="justify">As you can see in the first line, &#8220;all&#8221; css class is removed from the div displaying the message and then &#8220;messagebox&#8221; class is added to that that element with adding the text &#8220;checking&#8221; within the element and displaying with fading effect.</p>
<p align="justify">After that, ajax is used to call the PHP file, and when response is received through Ajax then jQuery is used to show the respective message-box with fading effects.</p>
<p align="justify"><strong>Php Code:</strong></p>
<pre class="prettyprint" style="overflow: auto">//this varible contains the array of existing users
$existing_users=array('roshan','mike','jason');
//value got from the get metho
$user_name=$_POST['user_name'];
//checking weather user exists or not in $existing_users array
if (in_array($user_name, $existing_users))
{
 //user name is not available
 echo "no";
}
else
{
  //username available i.e. user name doesn't exists in array
  echo "yes";
}</pre>
<p align="justify">In the above PHP code, I&#8217;ve added three usernames in a array and then check weather that user exists or not in that array and  print &#8220;yes&#8221; or &#8220;no&#8221; accordingly. The response taken from ajax is used within JavaScript function to  display the appropriate message.But, you can use database connection to check the the availability of username in your code.</p>
<p><strong><a href="http://roshanbh.com.np/codes/username-available.zip" target="_blank">Download full source</a></strong></p>
<img src="http://roshanbh.com.np/?ak_action=api_record_view&id=82&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html/feed</wfw:commentRss>
		<slash:comments>156</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/64 queries in 0.065 seconds using disk: basic
Object Caching 2230/2372 objects using disk: basic

Served from: roshanbh.com.np @ 2012-02-08 20:10:25 -->
