scriptaculous:slider.js スライダーの値を限定する

 script.aculo.usではスライダーの値を特定の値に限定することができます。例えば0〜100の範囲で0, 30, 60, 90, 100だけの値を取るようにすることができます。スライダー値を限定するにはControl.Slider()のオプションでvalue:[値1,値2,...,値n]を指定します。以下のサンプルは0〜100まで25ごとにしか値を取らないスライダーのサンプルです。(サンプルを実行する

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>スライダーの値を限定する</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="scriptaculous.js"></script>
<script type="text/javascript"><!--
window.onload = function ()
{
new Control.Slider("ptr", "back", { range:$R(0,100), values:[0,25,50,75,100], onSlide:dispValue, onChange:dispValue});
}
function dispValue(n)
{
$("result").innerHTML = n;
}
// --></script>
</head>
<body>
<h1>scriptaculous.js スライダーの値を限定する</h1>
<div id="back">
<div id="ptr"></div>
</div>
<div id="result"></div>
</body>
</html>

[目次へ]

(2006.7.4)