About the new html5 slider tag.
One thing to say that in a word it is amazing. The slider tag will allow you to set a range of value and allow you to set a initial value. You can do it just by a one line code.
The most left side of the bar is the minimum value, the right most is the maximum. users can slide the bar to the left or right to choose the value they like..Look below to see it in action and then we will go for the releated code
This is a slider to insert it just use one line code in your html code
<input type="range">
This one line will set the slider in your page now we will go step by step with example of this html5 slider. Now we will set the values for this html5 slider. To set the value for minimum and maximum we will add some more words with the existing codeThis is a slider to insert it just use one line code in your html code
<input type="range">
In this slider I have set min and max values and to do this I just add few words
<input type="range" min="0" max="100">
But still we can not see any output of the min/max value it's behavior is same as a slider without setting min/max value. Don't worry we will do everything but before this I like to show you another tricks of html5 slider.
Now we set a initial value for the slider as you can see the slider set himself a t middle as default but we have to customize it so we apply another attribute that is value
See this slider is set himself almost at the top right , how is it possible ?
See below
<input type="range" min="0" max="100" value="90">
Now we will go fto set the step value that means you can move the slider with a fix value. See the example below to understand
Move the slider and you can understand what is the difference.How will you do this ? Just add a more attribute "step"
<input type="range" min="0" max="100" value="90" step="10">
And lstly we are going to show the value for slider so that user can know what value they are choosing
To do this I wrote a simple javascript code that will show the value of the slider as you slide it..Here is the code. Now go and try this if you facing any problem please contact me
<span id="range">0</span>
<script type="text/javascript">
function showValue(newValue)
{
document.getElementById("range").innerHTML=newValue;
}
</script>
Hope this tutorial will help you.. Just get in touch I will provide more tutorial on html5 ,php, flash, photoshop and on web designing in web 2.0 style.
Sidd
Sidd