jeudi 29 juin 2017

Functions for disabling checkboxes not working corrently

The functionality is: When 1 of the checkboxes is checked, the other must be disabled. It's working, but after updating the WordPress page and trying to edit the checkbox, i got the following problem: enter image description here

First i've checked the Display Excerpt, then updated the page and as you can see, there are 2 boxes which are checked

Checkboxes"

<div><input type="checkbox" id="dx_article_excerpt" onclick="disableContentCheckbox()"><label for="dx_article_excerpt"><?php _e( 'Display Excerpt', 'dxeasypb' ); ?></label></div>
<div><input type="checkbox" id="dx_article_content" onclick="disableExcerptCheckbox()"><label for="dx_article_content"><?php _e( 'Display Content', 'dxeasypb' ); ?></label></div>

And here're the functions:

function disableContentCheckbox(){
            if (document.getElementById('dx_article_excerpt').checked) {
                document.getElementById("dx_article_content").disabled = true;
            } else {
                document.getElementById("dx_article_content").disabled = false;
            }
        }
        function disableExcerptCheckbox(){
            if (document.getElementById('dx_article_content').checked) {
                document.getElementById("dx_article_excerpt").disabled = true;
            } else {
                document.getElementById("dx_article_excerpt").disabled = false;
            }
        }

Why is this happening ?




Aucun commentaire:

Enregistrer un commentaire