-1

http://puu.sh/3r1jk.png

我有那个代码,最近实现了滑块。当滑块移动时,它会按照我的意愿更改获胜百分比。但如果我在输入中输入它,即 60%,它将更新乘数和利润。我希望它也通过滑块更新乘数和利润。

更新输入的代码:

$(document).ready(functon() {
    function updateValues() {
        // Grab all the value just incase they're needed.
        var chance = $('#chance').val();
        var bet = $('#bet').val();
        var pay = $('#pay').val();
        var profit = $('#profit').val();

        // Calculate the new payout.
        pay = Math.floor((9900 / (parseFloat(chance) + 0.5)) * 100) / 10000;


        // Calculate the new profit.
        profit = bet * pay - bet;
        profit = profit.toFixed(6);

        $('#chance').val(chance);
        $('#bet').val(bet);
        $('#pay').val(pay);
        $('#profit').val(profit);
    }


    parseFloat($('#chance').keyup(updateValues));
    parseFloat($('#bet').keyup(updateValues));
    parseFloat($('#pay').keyup(updateValues));
    parseFloat($('#profit').keyup(updateValues));
});

通过滑块更新获胜百分比的代码:

examples.push({

    range: [.01, 98],
    start: 49,
    handles: 1,
    connect: "lower",
    serialization: {
        to: [$(".exVal")]
    }

});

HTML:

<div class="form-box">
    <label for="bet">Bet Amount</label>
    <input type="text" name="bet" id="bet" class="text" placeholder="amount" />
</div>
<div class="form-box">
    <label for="pay">Multiplier</label>
    <input type="text" name="pay" id="pay" class="text" placeholder="Payout - 2x Default" />
</div>
<div class="form-box last">
    <label for="pay">Profit</label>
    <input type="text" name="profit" id="profit" class="text" placeholder="Profit" />
</div>
<div class="clearfix"></div>
<div class="form-box">
    <label for="chance">Win Chance (%)</label>
    <input type="text" name="chance" id="chance" class="text exVal" value="50" placeholder="Win % - 50.5% Default" />
</div>
<p>Slide to choose win chance or enter it in the input!</p>
<div class="noUiSlider" id="chance" style="margin: 25px 100px 10px 220px; colour:#00aec8;"></div>

为什么不更新?

4

1 回答 1

0

您在第一行“functon”而不是“function”中有错字。

也改变

parseFloat($('#chance').keyup(updateValues));
parseFloat($('#bet').keyup(updateValues));
parseFloat($('#pay').keyup(updateValues));
parseFloat($('#profit').keyup(updateValues));

$('#chance').keyup(updateValues);
$('#bet').keyup(updateValues);
$('#pay').keyup(updateValues);
$('#profit').keyup(updateValues);

编辑

此滑块没有事件,因此单击事件处理程序似乎只有选项

$('.noUiSlider, .noUiSlider *').click(updateValues);
于 2013-06-29T12:57:37.413 回答