Skip to Content
Menu
This question has been flagged
2 Replies
2790 Views

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
Discard
Best Answer

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
Discard
Best Answer

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
Discard
Related Posts Replies Views Activity
3
Nov 22
7985
1
Nov 22
2489
2
Aug 19
14496
0
Oct 16
3651
1
Mar 25
684