<?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>The html blog &#187; controls</title>
	<atom:link href="http://htmlblog.net/tag/controls/feed/" rel="self" type="application/rss+xml" />
	<link>http://htmlblog.net</link>
	<description>The web sandbox of Asvin Balloo</description>
	<lastBuildDate>Wed, 07 Oct 2009 17:20:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>YUI-based numeric stepper widget</title>
		<link>http://htmlblog.net/yui-based-numeric-stepper-widget/</link>
		<comments>http://htmlblog.net/yui-based-numeric-stepper-widget/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 16:08:20 +0000</pubDate>
		<dc:creator>asvin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[html xhtml]]></category>
		<category><![CDATA[numeric]]></category>
		<category><![CDATA[stepper]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yui]]></category>

		<guid isPermaLink="false">http://htmlblog.net/?p=20</guid>
		<description><![CDATA[

Since I had some problems with YUI slider, I decided to write a YUI-based numeric stepper that allows users to select values within a predefined range.

To instantiate the widget include the following files :
&#160;
&#60;!-- CSS --&#62;
&#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;stepper/stepper.css&#34; /&#62;
&#160;
&#60;!-- Dependencies --&#62;
&#60;script type=&#34;text/javascript&#34; src=&#34;http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&#34;&#62;&#60;/script&#62;
&#160;
&#60;!-- Stepper source file --&#62;
&#60;script type=&#34;text/javascript&#34; src=&#34;stepper/stepper-min.js&#34;&#62;&#60;/script&#62;
&#160;
Then place your stepper in your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://htmlblog.net/demo/stepper/"><img src="http://htmlblog.net/wp-content/uploads/2008/07/stepper.png" alt="" title="stepper" width="444" height="126" class="alignleft size-full wp-image-21" /></a></p>
<div style="clear:both;"></div>
<p>Since I had some problems with <a href="http://developer.yahoo.com/yui/slider/">YUI slider</a>, I decided to write a <a href="http://developer.yahoo.com/yui/">YUI-based</a> numeric stepper that allows users to select values within a predefined range.<br />
<span id="more-20"></span><br />
To instantiate the widget include the following files :</p>
<pre class="html4strict">&nbsp;
<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- CSS --&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000; font-weight: bold;">&lt;link</span></a> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;stepper/stepper.css&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Dependencies --&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Stepper source file --&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;stepper/stepper-min.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span>
&nbsp;</pre>
<p>Then place your stepper in your body :</p>
<pre class="html4strict">&nbsp;
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;stepperValue&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>10 px<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;stepperControls&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;stepperUp&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;stepper/add.gif&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;stepperDown&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;stepper/sub.gif&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;clear:both&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
&nbsp;</pre>
<p>The <strong>stepperValue</strong> id will display the current value of the stepper.<br />
The <strong>stepperControls</strong> will contain the different controls for our stepper, and you can place it anywhere you want and use whatever images you want.</p>
<p>Finally when the <a href="http://developer.yahoo.com/yui/event/#ondomready">DOM is ready</a>, instantiate the widget :</p>
<pre class="javascript">&nbsp;
&lt;script type=<span style="color: #3366CC;">&quot;text/javascript&quot;</span>&gt;			
	YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Event</span>.<span style="color: #006600;">onDOMReady</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> mystepper = <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #006600;">widget</span>.<span style="color: #006600;">Stepper</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">10</span>, <span style="color: #3366CC;">'stepperUp'</span>, <span style="color: #3366CC;">'stepperDown'</span>, <span style="color: #CC0000;">0</span>, <span style="color: #CC0000;">200</span>, <span style="color: #CC0000;">10</span><span style="color: #66cc66;">&#41;</span>;
		mystepper.<span style="color: #006600;">onChange</span>.<span style="color: #006600;">subscribe</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'stepperValue'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">innerHTML</span> = mystepper.<span style="color: #006600;">getValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">' px'</span>;
		<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&lt;/script&gt;
&nbsp;</pre>
<p>The stepper takes 6 parameters, all mandatory (check source code) :</p>
<pre class="javascript">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> mystepper = <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #006600;">widget</span>.<span style="color: #006600;">Stepper</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">10</span>, <span style="color: #3366CC;">'stepperUp'</span>, <span style="color: #3366CC;">'stepperDown'</span>, <span style="color: #CC0000;">0</span>, <span style="color: #CC0000;">200</span>, <span style="color: #CC0000;">10</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<ul>
<li>1. the initial value</li>
<li>2. the ID of the element for the up control button</li>
<li>3. the ID of the element for the down control button</li>
<li>4. the minimum value the stepper can decreased to</li>
<li>5. the maximum value the stepper can increased to</li>
<li>6. by how much the stepper is incremented/decremented after each click</li>
</ul>
<p>We listen for any change to the stepper and in this case, display the updated value in the container we defined earlier on ( stepperValue) using <a href="http://developer.mozilla.org/en/docs/DOM:element.innerHTML">innerHTML</a>.</p>
<pre class="javascript">&nbsp;
mystepper.<span style="color: #006600;">onChange</span>.<span style="color: #006600;">subscribe</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
			YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'stepperValue'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">innerHTML</span> = mystepper.<span style="color: #006600;">getValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">' px'</span>;
		<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p>You can get the current value of the stepper by calling :</p>
<pre class="javascript">&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> currentValue = mystepper.<span style="color: #006600;">getValue</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;</pre>
<p><a href="http://htmlblog.net/demo/stepper/"><strong>Live demo</strong></a><br />
<a href="http://htmlblog.net/demo/stepper/stepper.zip"><strong>Download source code (including demo)</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://htmlblog.net/yui-based-numeric-stepper-widget/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
