跳至内容
菜单
此问题已终结
2 回复
2719 查看

hello everyone,

I was trying to make some changes in my xml custom template 

where if checkbox is checked then show the select tag

it would be really great if you could help me in it

xml:


                                    <t t-if="contract.partner_id.payment_token_ids">
                                        Do you want to enable auto pay? <input type="checkbox"/>
                                            <div class="col-md-5 col-sm-5">
                                                <select class="form-control" id="check_id" name="select_card">                
                                                    <t t-foreach="contract.partner_id.payment_token_ids" t-as="card">
                                                          <option id="show_cards" t-att-value="card[0]"><t t-esc="card[0].name"/></option>
                                                          </t>
                                                </select>
                                            </div>
                                    </t>





形象
丢弃
最佳答案

t t-if="contract.partner_id.payment_token_ids"
Do you want to enable auto pay? 

input type="checkbox" id="auto_pay_checkbox"/
div class="col-md-5 col-sm-5"
select class="form-control" id="check_id" name="select_card" style="display:none"
t t-foreach="contract.partner_id.payment_token_ids" t-as="card"
option id="show_cards" t-att-value="card[0]">/option
/t
/select
/div
/t
script
$(document).ready(function(){
$("#auto_pay_checkbox").change(function(){
if(this.checked)
$("#check_id").show();
else
$("#check_id").hide();
});
});
/script

形象
丢弃
最佳答案

Hi,

You could try the following:-

<t t-if="contract.partner_id.payment_token_ids">


    Do you want to enable auto pay?


    <input type="checkbox" id="checkbox_1" onclick="onclick_checkbox()"/>


    <div class="col-md-5 col-sm-5">


        <select class="form-control" id="check_id" name="select_card">


            <t t-foreach="contract.partner_id.payment_token_ids" t-as="card">


                <option id="show_cards" t-att-value="card[0]">


                    <t t-esc="card[0].name"/>


                </option>


            </t>


        </select>


    </div>


</t>


< script>
function onclick_checkbox(){
var checkBox = document.getElementById("checkbox_1");
var select = document.getElementById("check_id");
if (checkBox.checked == true){
select.style.display = "none";
} else {
select.style.display = "block";
}
}
< /script>

Regards

形象
丢弃
相关帖文 回复 查看 活动
3
11月 22
7859
1
11月 22
2449
2
8月 19
14394
0
10月 16
3602
1
3月 25
622