Skip to content

Instantly share code, notes, and snippets.

@MartijnR
Last active August 4, 2016 19:19
Show Gist options
  • Save MartijnR/432da4c84ee876ff7b240814c859f0bf to your computer and use it in GitHub Desktop.
Save MartijnR/432da4c84ee876ff7b240814c859f0bf to your computer and use it in GitHub Desktop.
Form that contains a repeat with a condition to not show a question if subsequent repeats if the current repeat has a certain value
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>repeat-do-not-ask-again</h:title>
<model>
<instance>
<repeat-do-not-ask-again id="repeat-do-not-ask-again">
<rep jr:template="">
<txt/>
<number/>
</rep>
<meta>
<instanceID/>
</meta>
</repeat-do-not-ask-again>
</instance>
<bind nodeset="/repeat-do-not-ask-again/rep/txt" type="string"/>
<bind nodeset="/repeat-do-not-ask-again/rep/number" relevant="count(../preceding-sibling::rep[./txt = 'yes']) = 0" type="int"/>
</model>
</h:head>
<h:body>
<group ref="/repeat-do-not-ask-again/rep">
<label>Repeated group</label>
<repeat nodeset="/repeat-do-not-ask-again/rep">
<input ref="/repeat-do-not-ask-again/rep/txt">
<label>1. Enter 'yes' to hide question 2 in subsequent repeats.</label>
</input>
<input ref="/repeat-do-not-ask-again/rep/number">
<label>Enter a number</label>
<hint>2. Will only be shown if none of the previous repeats have the answer 'yes' to question 1.</hint>
</input>
</repeat>
</group>
</h:body>
</h:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment