Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1609
  • Last Modified:

HTML SELECT to jQuery Spinner?

I'd like to interface my ASP.NET dropdownlist controls (which render as HTML SELECTs) a different way:  like a numeric spinner, or "updown" control.

You know, where you have up/down arrow buttons or arrow buttons to the left and right of the control area.  When you click left (or down), you move backwards through the SELECT items.  When you click right (or up) you advance forward through the SELECT items.

Everything else would function the same.

Has anyone seen anything like this?  The best solution, in my mind, would be a jQuery widget that "acts on" a SELECT and modifies that select to work in a spinner format.

You would still be able to retrieve both option.VALUE and option.TEXT from the spinner control, just like with the HTML SELECT.

I have been hammering Google and I do not believe such a thing exists, but I want to poll to make sure.

Also, I do NOT want to take the time to develop one myself.

Thanks very much.
0
bamapie
Asked:
bamapie
  • 7
  • 6
1 Solution
 
Michel PlungjanIT ExpertCommented:
0
 
bamapieAuthor Commented:
That looks like something that just takes a text box and converts it into a numeric spinner.

I'm talking about something that takes an HTML SELECT and changes it into a spinner--retaining all the text labels (which would be what you would see as you spin through the items).  You would not see numerics.  You'd see the same items as you populated your HTML SELECT with.
0
 
Michel PlungjanIT ExpertCommented:
Ok I'll see what I can find or make
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Michel PlungjanIT ExpertCommented:
Here you go

http://jquery.anantanandgupta.net/plugins/jQuerySpinnerControl/demo/3/

Please download the code instead of deep linking like I did.

Note the optional hiding of the select

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="http://jquery.anantanandgupta.net/plugins/jQuerySpinnerControl/demo/3/" />
    <title>jQuery Spinner Control - Spinning List of Items</title>
    <link href="../../../Styles/SpinnerControl/jquery.spinnercontrol.css" rel="stylesheet" type="text/css" />
    <link href="../../../Styles/jquery.snippet.min.css" rel="stylesheet" type="text/css" />
    <link href="../../../Styles/SiteTemplate.css" rel="stylesheet" type="text/css" />
    <link href="../../../Styles/SpinnerControl/pluginSite.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/jquery.js" type="text/javascript"></script>

    <script src="../../../Scripts/SpinnerControl/jquery.spinnercontrol.js" type="text/javascript"></script>
    <script src="../../../Scripts/jquery.snippet.min.js" type="text/javascript"></script>
</head>
<body>
    <div class="pageContainer">
        <div class="pageHeader">
            jQuery Spinner Control - converting a select to spinners
        </div>
        <div class="pageContents">
            <div class="heading">
                Code: Spinning List of Items
            </div>
            <div id="selcontainer">
            input select: <select id="sel1">
            <option value="">Please select</option>
            <option value="Value 1">Text 1</option>
            <option value="Value 2">Text 2</option>
            <option value="Value 3">Text 3</option>
            <option value="Value 4">Text 4</option>
            <option value="Value 5">Text 5</option>
            <option value="Value 6">Text 6</option>
            <option value="Value 7">Text 7</option>
            <option value="Value 8">Text 8</option>
            <option value="Value 9">Text 9</option>
            </select>
            </div>
            <div class="heading">
                Output:
            </div>
            <div class="OutputContainer">
                <div style="float: left; overflow: auto; padding: 0 10px;">
                    <div>
                        values:</div>

                    <input type="text" id="txtValues" />
                </div>
                <div style="float: left; overflow: auto; padding: 0 10px;">
                    <div>
                        text:</div>
                    <input type="text" id="txtText" />
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    $(function () {
        var opts = $("#sel1 option"), list1=[], list2=[];
        $.each(opts,function(){
          var opt = $(this);
          if (opt.attr("value")) {
            list1.push(opt.attr("value"));
            list2.push(opt.text());
          } 
        });
        $("#selcontainer").hide(); // hide the select we just converted
        
        $("#txtValues").SpinnerControl({ type: 'list',
            typedata: {
                list: list1.join(",")
            },
            width: '100px',
            looping: true
        });
        $("#txtText").SpinnerControl({ type: 'list',
            typedata: {
                list: list2.join(",")
            },
            width: '100px',
            looping: true
        });
        $("pre.javascript").snippet("javascript", { showNum: false, transparent: false, style: "zellner" });
    })
</script>
</html>

Open in new window

0
 
bamapieAuthor Commented:
Oh, wow.  Okay, give me a day or two to find the time to plug it in and give this a shot.

Thanks!  I hope you get more mileage out of these than just me!  This could have some legs if it works.
0
 
bamapieAuthor Commented:
Okay.  I like how it behaves.

How do I hook the (change) event?  Like, if I need to react upon each click? (like the change event in the Html SELECT)

And how would I simply read the currently-selected .text and .value properties of this new spinner control?

Thanks!
0
 
Michel PlungjanIT ExpertCommented:
It just posts to the server as the original text input
0
 
bamapieAuthor Commented:
So, if I wanted to hook the onChange() event on the client side and do something, I would just hook the onChange event of the original <select>?
0
 
Michel PlungjanIT ExpertCommented:
Hmm not in my implementation

You (or I, if you want) need to hook
$("div.RightButton".click(...)
0
 
bamapieAuthor Commented:
I'm so sorry I'm just now looping back through this.

Am I reading this right, that I need to hook $('div.RightButton').click(), or is it ('divRightButton').click()?
0
 
Michel PlungjanIT ExpertCommented:
div.RightButton

<div class="RightButton"></div>
0
 
Amandeep Singh BhullarCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
Michel PlungjanIT ExpertCommented:
0
 
bamapieAuthor Commented:
I'll have to try this where I can hook that click event.  That was the piece I was missing that prevented me deploying this idea previously.

Thanks
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now