标签不适用于复选框 - 不保存 checked/nonchecked
Label not working with checkbox - not saves the checked/nonchecked
滑动完美。只是如果我检查它不保存选项 checked/unchecked。我知道 ( {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if}
).
有问题
<div class="switch-box col-xs-6 col-sm-2 col-md-2 col-lg-2 no-hor-padding" style="width:50%;">
<div class="switch-1 col-xs-12 col-sm-12 col-md-12 col-lg-12 no-hor-padding">
{if $pe_settings[$fieldset].use_negotiable==1}
<input type="checkbox" class="cmn-toggle-1 cmn-toggle-round-1" name="negotiable" id="negotiable" {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if} value="0" />
<label for="negotiable"></label>
{$pe_settings[$fieldset].lang[$crt_lang].negotiable}
{/if}
</div>
</div>
如果我删除
> <label for="negotiable"></label>
有效并保存选项。
JavaScript:
<script>
{literal}
$(document).ready(function() {
$("#negotiable").click(function() {
if( $(this).attr('checked') ){
$("#negotiable").val('0');
$('#negotiable').removeAttr('checked');
}else{
$("#negotiable").val('1');
$('#negotiable').attr('checked','checked');
}
});
});
{/literal}
</script>
如果您使用复选框,则不应更改该值。复选框的工作方式类似于,如果选中复选框,则提交值;如果未选中复选框,则不提交值。
<input type="checkbox" class="cmn-toggle-1 cmn-toggle-round-1" name="negotiable" id="negotiable" {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if} value="1" />
基本上,您应该将复选框的值设置为“1”
滑动完美。只是如果我检查它不保存选项 checked/unchecked。我知道 ( {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if}
).
<div class="switch-box col-xs-6 col-sm-2 col-md-2 col-lg-2 no-hor-padding" style="width:50%;">
<div class="switch-1 col-xs-12 col-sm-12 col-md-12 col-lg-12 no-hor-padding">
{if $pe_settings[$fieldset].use_negotiable==1}
<input type="checkbox" class="cmn-toggle-1 cmn-toggle-round-1" name="negotiable" id="negotiable" {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if} value="0" />
<label for="negotiable"></label>
{$pe_settings[$fieldset].lang[$crt_lang].negotiable}
{/if}
</div>
</div>
如果我删除
> <label for="negotiable"></label>
有效并保存选项。
JavaScript:
<script>
{literal}
$(document).ready(function() {
$("#negotiable").click(function() {
if( $(this).attr('checked') ){
$("#negotiable").val('0');
$('#negotiable').removeAttr('checked');
}else{
$("#negotiable").val('1');
$('#negotiable').attr('checked','checked');
}
});
});
{/literal}
</script>
如果您使用复选框,则不应更改该值。复选框的工作方式类似于,如果选中复选框,则提交值;如果未选中复选框,则不提交值。
<input type="checkbox" class="cmn-toggle-1 cmn-toggle-round-1" name="negotiable" id="negotiable" {if isset($tmp.negotiable) && $tmp.negotiable==1}checked="checked"{/if} value="1" />
基本上,您应该将复选框的值设置为“1”