jeudi 23 juin 2016

Alternating the check of checkboxes using labels and javascript ASPX HTML

Just after a little bit of help.

trying to make 2 of my checkboxes act as radio buttons for the UI i have. Please don't say use radio buttons as that is not an option.

Code:

<div class="centrerow">
            <div class="groupmulti">
                <label class="centrerow">&nbsp;</label>
                <input type="checkbox" id="radAlloc" name="radAllocType1" data-type="1" onclick="if (this.checked) { document.getElementById('radUnAlloc').checked = 0; document.getElementById('radUnalloc').removeClass = ('ui-state-active') }" <%=Request("hidAllocType1")%> value="3"/>
                <label for="radAlloc">Online Users Only</label>
                <input id="hidAllocType1" name="hidAllocType1" type="hidden" value="" />

                <label class="centrerow">&nbsp;</label>
                <input type="checkbox" id="radUnAlloc" name="radAllocType2" data-type="2" onclick="if (this.checked) { document.getElementById('radAlloc').checked = 0; document.getElementById('radAlloc').removeClass = ('ui-state-active') }" <%=Request("hidAllocType2")%> value="4"/>
                <label for="radUnAlloc">Exclude Online Users</label>
                <input id="hidAllocType2" name="hidAllocType2" type="hidden" value="" />
            </div>
        </div>

I am getting the error: frmUserSecuritySummary.aspx:711 Uncaught TypeError: Cannot set property 'removeClass' of null

I believe what is happening is that the checkbox is unchecking but the label is not changing to reflect this.

i have tried adding a 2nd document.getElementById to do this but this is when i get the above error.

My theory is i need to remove the class ('ui-state-active') from the opposite checkbox, as this is the only thing i can see changing on selection of the checkbox.

Any suggestions would be most welcome.




Aucun commentaire:

Enregistrer un commentaire