gpt4 book ai didi

javascript - jQuery Mobile - Spinbox - 多个依赖的 Spinbox

转载 作者:行者123 更新时间:2023-12-03 10:52:09 27 4
gpt4 key购买 nike

在 jquery 移动应用程序中,我必须使用三个依赖的旋转框,如下图所示 enter image description here

目前正在使用这个插件

http://dev.jtsage.com/jQM-Spinbox/

成人/ child /婴儿的最大值为 9

此外,婴儿数量不应大于成人数量。我创建了一个验证函数,它将在单击向上/向下按钮时调用。但所做的更改不会影响其他旋转框

下面的代码我已为婴儿设置了“max”属性,但它不起作用

    <div class="ui-field-contain">
<label for="adult">ADULT</label>
<input type="text" data-mini="true" data-role="spinbox" name="spin4" id="adult" data-options='{"type":"vertical"}' value="1" min="0" max="9" />

<label for="child">CHILD</label>
<input type="text" data-mini="true" data-role="spinbox" name="child" id="child" data-options='{"type":"vertical"}' value="0" min="0" max="9" />

<label for="infant">Infant</label>
<input type="text" data-mini="true" data-role="spinbox" name="infant" id="infant" data-options='{"type":"vertical"}' value="0" min="0" max="9" />
</div>


// id is the id of spinbox .ie adult, i=child, infant

setValidations:function(id){
console.log("selected id="+id);
console.log("selected id value ="+$("#"+id).val());
$("#infant").attr("max",$("#adult").val())
$("#infant").enhanceWithin();
}

任何帮助将不胜感激。

最佳答案

setValidations:function(id){

$("#infant").attr("max",$("#adult").val())
$("#infant").spinbox({"dmax":$("#adult").val()});
$("#child").spinbox({"dmax":9-$("#adult").val()});
if(id == 'adult') {
$("#child").val(0);
$("#infant").val(0);
}
}

关于javascript - jQuery Mobile - Spinbox - 多个依赖的 Spinbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28392301/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com