lundi 14 janvier 2019

Disable checkbox by clicking another checkbox (HTML/DJANGO)

I have 2 checkboxes on my site. One of them gives me opportunity (or not) to click(change state) second one. So if first checkbox is checked I can change state of second but if first checkbox is unchecked then I just can't (checkbox is disabled).

So I wrote simple if/else statement in html (with django python) and it looks like :


    
        <input id="myCheck" type="checkbox" disabled="disabled">
    


Maybe some of you are confused why I have if statement for second checkbox, I just check his last value from database to know that it was True or False. I checked that code and it doesn't work good. I mean If I refresh page after each change state of first checkbox it works but is should work all the time without refreshing page all the time. What I'm doing wrong ?




Aucun commentaire:

Enregistrer un commentaire