1

Topic: Checkboxes not ticked when edit a record

If a user edits a record (eg from a My records page) which has an Occurrence attribute in a select list, the correct record is shown in the list. In the case below, 'Frequent', since it has the selected="selected" attribute.

<select id="sc:species-grid-76-0:696742:occAttr:21:777405" name="sc:species-grid-76-0:696742:occAttr:21:777405" class="scAbundance ">
<option value=""></option>
<option value="1">Dominant</option>
<option value="2">Abundant</option>
<option value="3" selected="selected">Frequent</option>
<option value="4">Occasional</option>
<option value="5">Rare</option>
</select> 

In the same form, if there is a list of checkboxes the one/s which were ticked have the attribute 'selected="selected"' (conventionally it would be "checked" for checkboxes) and nothing is ticked. Ideally it would show these checkboxes with a tick. Is this a bug and/or do I need to do something different:

<ul class="scAnnualCycle control-box " id="sc:species-grid-76-0::occAttr:137[]">
<li><input type="checkbox" name="sc:species-grid-76-0::occAttr:137[]" id="sc:species-grid-76-0::occAttr:137:0" value="377" class=" first-item" /><label for="sc:species-grid-76-0::occAttr:137:0">Bare</label></li>
<li><input type="checkbox" name="sc:species-grid-76-0::occAttr:137[]" id="sc:species-grid-76-0::occAttr:137:1" value="378:777406" selected="selected"/><label for="sc:species-grid-76-0::occAttr:137:1">Leaves</label></li>
<li><input type="checkbox" name="sc:species-grid-76-0::occAttr:137[]" id="sc:species-grid-76-0::occAttr:137:2" value="379" /><label for="sc:species-grid-76-0::occAttr:137:2">Flowers</label></li>
<li><input type="checkbox" name="sc:species-grid-76-0::occAttr:137[]" id="sc:species-grid-76-0::occAttr:137:3" value="380" /><label for="sc:species-grid-76-0::occAttr:137:3">Fruits</label></li>
</ul> 

2 (edited by namwebs 16-08-2024 11:28:37)

Re: Checkboxes not ticked when edit a record

It seems like this forum is dead... but I'll answer my own question.

I still don't understand why they are marked as 'selected' instead of 'checked' but I used this css to get the checkboxes to be ticked:

/*workaround to get form checkboxes to show as ticked when code is 'selected' instead of 'checked' */

input[type="checkbox"][selected="selected"]::after {
    content: "✔";
    position: relative;
    font-size: 1.2em;
    bottom: 2px;
    left: 1px;
    font-weight: bold;
}