We have many forms that are a checklist of tasks for the maintenance technician to perform, say for an annual motor vehicle inspection. Each tasks has a radio-button for the technician confirm whether the task was completed or not (e.g. Done/Not done, or OK/Not OK, etc) and they are all in the same section on the form.
We want button that calls an Action to default all these radio-buttons in the section to OK or Done to speed up the process..
I have tried the following code, but it sets all the Done values, then the 2nd statement clears the Done values and sets the OK values. How can we get it to do both?
<xf:action event="DOMActivate">
<xf:setvalue xxf:iterate="//SubScn2YearlyMaintenance//*[empty(*)]" value="if (//* != '') then 'Done' else ."/>
<xf:setvalue xxf:iterate="//SubScn2YearlyMaintenance//*[empty(*)]" value="if (//* != '') then 'OK' else ."/>
</xf:action>
We know we can set each field individually, but there can be upwards of 50 tasks to perform, and we would want some simple code to set all the Done/OK values if possible.
Example form
Many thanks in advance.
PeteA
With something along those lines work for you?
<xf:action event="DOMActivate">
<xf:setvalue
xxf:iterate="
//SubScn2YearlyMaintenance
//*[
empty() and
exists(
xxf:itemset(concat(local-name(), '-control'), 'xml')
//item/value[. = ('checked')]
)
]"
value="if (// != '') then 'checked' else ."/>
</xf:action>
PS: This answer has been updated per OP's feedback.