Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html form input slider / range with non numeric values?

<input type="range" min="2" max="52" value="4" step="1"/>

Can I have one of these input ranges with non-numeric intervals? Like "Yes" then "maybe" then "no"?

Thanks

like image 990
user852974 Avatar asked Mar 26 '26 11:03

user852974


1 Answers

The type range of html input is designed for imprecise input values.

Anyway, if you really want to use a slider for this purpose, you can maybe set on your script that 0 is no, 1 is maybe and 2 is yes. In jQuery, it would be something like this:

$("#slider").change(function(){
    switch($(this).val()){
        case "0":
          /* change a text/hidden value to 'no' */
          break;
        case "1":
          /* change a text/hidden value to 'maybe' */
          break;
        case "2":
          /* change a text/hidden value to 'yes' */
          break;
      }
}).change();

Live example: http://jsbin.com/upeyew

like image 122
v42 Avatar answered Mar 28 '26 23:03

v42