开发者

Upper/Downy controls for HTML

In开发者_如何学C Windows Forms apps, you can add an upper downy control to the form. It just has a textbox with two buttons next to it, that let you increment or decrement the value in the textbox on the left. Is there a control like that for HTML? I haven't been able to find one.


You can style it how you like, but you can implement it as follows...

<p><input type="text" name="uppydowner" id="uppydowner" value="1" size="2"> 
    <span id="uppy"></span> <span id="downy"></span></p>

<script type="text/javascript">
    var upButton = document.getElementById("uppy");
    var downButton = document.getElementById("downy");
    var resultBox = document.getElementById("uppydowner");

    upButton.innerHTML = "+";
    downButton.innerHTML = "-";

    upButton.onclick = function () {
        var current = parseInt(resultBox.value);
        current++;
        resultBox.value = current;
    };

    downButton.onclick = function () {
        var current = parseInt(resultBox.value);
        current--;
        resultBox.value = current;
    };
</script>


It does not exist, you must build this behaviour with JavaScript.

You place a textarea or a div and use JavaScript to scroll the content up or down.

I've read about it somewhere in the past, but I can't recall where, sorry... :\


You can use this control : http://www.onlinetools.org/tests/countertest.html . It is a simple javascript modification of the input control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜