Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
2 Besvarelser
3086 Visninger

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>





Avatar
Kassér
Bedste svar

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

Avatar
Kassér
Bedste svar

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

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
3
nov. 22
8418
1
nov. 22
2788
2
aug. 19
15170
0
okt. 16
3916
1
mar. 25
1270