Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
2860 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
nov. 22
8092
1
nov. 22
2558
2
aug. 19
14655
0
okt. 16
3703
1
mrt. 25
815