<?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>Tue, 09 Nov 2010 11:39:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<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 : &#60;!-- CSS --&#62; &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;stepper/stepper.css&#34; /&#62; &#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; &#60;!-- Stepper source file --&#62; &#60;script [...]]]></description>
			<content:encoded><![CDATA[<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="brush: xhtml">
&lt;!-- CSS --&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;stepper/stepper.css&quot; /&gt;

&lt;!-- Dependencies --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://yui.yahooapis.com/2.5.2/build/yahoo-dom-event/yahoo-dom-event.js&quot;&gt;&lt;/script&gt;

&lt;!-- Stepper source file --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;stepper/stepper-min.js&quot;&gt;&lt;/script&gt;
</pre>
<p>Then place your stepper in your body :</p>
<pre class="brush: xhtml">
&lt;div id=&quot;stepperValue&quot;&gt;10 px&lt;/div&gt;
&lt;div class=&quot;stepperControls&quot;&gt;
	&lt;div id=&quot;stepperUp&quot;&gt;&lt;img src=&quot;stepper/add.gif&quot; /&gt;&lt;/div&gt;
	&lt;div id=&quot;stepperDown&quot;&gt;&lt;img src=&quot;stepper/sub.gif&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;
</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="brush: javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
	YAHOO.util.Event.onDOMReady(function(){
		var mystepper = new YAHOO.widget.Stepper(10, &#039;stepperUp&#039;, &#039;stepperDown&#039;, 0, 200, 10);
		mystepper.onChange.subscribe(function(){
			YAHOO.util.Dom.get(&#039;stepperValue&#039;).innerHTML = mystepper.getValue() + &#039; px&#039;;
		});
&lt;/script&gt;
</pre>
<p>The stepper takes 6 parameters, all mandatory (check source code) :</p>
<pre class="brush: javascript">
var mystepper = new YAHOO.widget.Stepper(10, &#039;stepperUp&#039;, &#039;stepperDown&#039;, 0, 200, 10);
</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="brush: javascript">
mystepper.onChange.subscribe(function(){
			YAHOO.util.Dom.get(&#039;stepperValue&#039;).innerHTML = mystepper.getValue() + &#039; px&#039;;
		});
</pre>
<p>You can get the current value of the stepper by calling :</p>
<pre class="brush: javascript">
var currentValue = mystepper.getValue();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://htmlblog.net/yui-based-numeric-stepper-widget/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

