Skip to Content
Menú
This question has been flagged
2 Respostes
3089 Vistes

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
Descartar
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
Descartar
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
Descartar
Related Posts Respostes Vistes Activitat
3
de nov. 22
8418
1
de nov. 22
2788
2
d’ag. 19
15170
0
d’oct. 16
3916
1
de març 25
1270