lundi 22 juin 2015

checkbox updating another checkbox on different form

my first javascript is not working, hope you can help.

I am trying to make a checkbox on one form check a checkbox on another form. This is based on this link: check/uncheck checkbox based on another checkbox

Here is my simplified code

<formname="A"
action="WebPage.php" method="POST">
<input type="checkbox" name="Aa" onchange="update()" value="Aa"/>Aa
<script type="text/javascript">
    function update(){
        var original = document.getElementById('Aa');
        var other = document.getElementById('Ba');
        original.checked = other.checked;
    }
</script>    
</form>
<formname="B"
action="WebPage.php" method="POST">
<input type="checkbox" name="Ba" value="Ba"/>Ba
</form>

This is not working. Checking Aa does nothing to Ba.

In case I am going down the wrong path, if this can work, then I will change it so checking Aa unchecks Ba, Bb, Bc, and other checkboxes on form B. Then I want to add a function on form B so that checking any one or all checkbox(es) there will cause Aa to be unchecked.

I am at the very beginning of website design, so I appreciate your advice on the best direction to go.

Thanks, Dan




Aucun commentaire:

Enregistrer un commentaire