1

ある種の登録フォームを作成しています。名前などに FORM タグを使用しました。スライダーも必要です。jqueryでスライダーを作成しました。PHPスクリプトのFORMタグ入力からのように、このスライダーから値を「転送」する方法はありますか? ありがとう

<p style="text-align: center">Amount: <span id="amountDisp" style="color: #ff0000">500</span><div id="amount_slider"></div></p>

function () {
$("#amount_slider").slider({
            handle: "myhandle",
    orientation: "horizontal",
    range: false,
    min: 500,
    max: 4999,
    value: 500,
    step: 1,
            animate: true,
    change: function (event, ui) {
        $("#amount").text(ui.value);
        calculate();
    },
            slide: function (event, ui) {
        $("#amountDisp").text(ui.value);
    }
});
4

1 に答える 1

0

サーバー上のphpに値を投稿するには、スライダーが変更されたときに値を保持するテキストフィールドが必要です。非表示の入力を使用できます。この非表示の入力に値を設定すると、他のフォーム要素と一緒に投稿されます。

html を次のように変更します --

<p style="text-align: center">
   Amount: <span id="amountDisp" style="color: #ff0000">500</span>
   <div id="amount_slider"></div>
   <input type="text" id="amount_field">
</p>

hiddenデモ目的で入力を使用せず、js を -- に変更しました。

$("#amount_slider").slider({
    handle: "myhandle",
    orientation: "horizontal",
    range: false,
    min: 500,
    max: 4999,
    value: 500,
    step: 1,
    animate: true,
    change: function (event, ui) {       
        $("#amount_field").val(ui.value);
        $("#amountDisp").text(ui.value);
        calculate();
    },
     slide: function (event, ui) {
        $("#amount_field").val(ui.value);
        $("#amountDisp").text(ui.value);        
    }
});

デモを見る

アップデート

送信フォームに使用している場合は、-ajaxから値を直接選択できます。amountDisp

var sliderAmount = $("#amountDisp").text();
于 2013-03-31T18:39:54.507 に答える