Script. aculo. US development series (9): Use of the slider Control

Source: Internet
Author: User
The slider control is a script. aculo. another major feature of us is that the slider control is an element that can slide on an element (slider) and calculate the sliding ratio. If you look at the ajaxcontroltoolkit, it's nothing more than dragging some controls and setting some properties, so I am glad to think that I have learned Asp.net Ajax. In fact, it is not the case that the deeper things are still in JavaScript programming.

Declaration Method New Control. Slider ('Id _ of_slider_handle ', 'Id _ of_slider_track', [Options]);
    • Axis: the direction of the slider: horizontal or vertical. The default value is
    • Increment: I didn't see any usage.Source codeIt appears twice
    • Alignx: The allowable width of the slider, which is also the range of the width. For example, if the original width of the slider is 200 and alignx is set to 100, the maximum drag position is 100, in the calculation, it is determined that the location here is 100%
    • Aligny: allowable height of the slider
    • Disabled: True/false; default value: false
    • Maximum/minimum: maximum and minimum values
    • Slidervalue: initial value. The default value is 0.
    • Values: a set of allowed values, an array.
    • Range: range. It is generally generated using $ (minimum, maximum). The default value is $ R (0, 1)
    • Onslide (): slide is used to call this function. The parameter value is accepted to indicate the current value.
    • Onchange (): When the activity ends, this method is called to accept the current value of the parameter value.
    • Setvalue (value): You can directly call this function to set the value.
    • Setdisabled ()/setdisabled (): sets the disable attribute.

Source of the exampleCode

VaR Oslider = Null ;
Function Init ()
{
Oslider = New Control. Slider ( " Slider " , " Slidercontainer " ,
{
Axis: 'horizontal ', // Horizontal Direction
Handleimage: " Imgslider " , // ?
Handledisabled: " Imgslider2 " , // ?
Slidervalue: 120 , // Initial Value: 120
Range: $ R ( 40 , 240 ), // The value range is 40 to 40 ~ 240
// Increment: 10,
// Minimum: 40,
// Maximum: 240,
Values :[ 40 , 80 , 120 , 160 , 200 , 240 ], // Allowed value
// Alignx: 200,
Onslide: Function (V) {$ ('co'). innerhtml = 'Current value :' + V; $ ( " Divtarget " ). Style. Width = V + 'Px ';},
Onchange: Function (V) {$ ('co'). innerhtml = 'Change, current value' + V ;}< BR >});

}< br> event. observe (window, 'load', init);

function set80 ()
{< br> oslider. setvalue ( 80 );
}

function disable ()
{< br> oslider. s Etdisabled ();
}

function enable ()
{< br> oslider. setenabled ();
}

when calculating a value, Slider uses minimum + percentage * (maximum-minimum) to calculate the final value, so in the above example, it cannot be 0.

until now, script. aculo. this is the first time that we have written such a long series of articles , there may be a lot of details or inaccuracies. please correct me. my email: yanghengfeng@163.com Thn X a lot!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.