Custom code for setting default value for Yes/No Data element in Event Capture forms

Hi all,

I have data elements of value type: ‘Yes/No’ with the attributes below: What would be the custom form code for setting the default value at runtime to ‘NO’?

<select id=“bEGgpe8yxet-vwt4lpdqcbz-val” name=“vwt4lpdqcbz”

class=“ng-binding”>[Please Select]<option value=“false”

class=“ng-binding”>NO<option value=“true”

class=“ng-binding”>YES

The Jquery code below works with ordinary select fields; however, for the field above, it doesn’t seem to work.

$(select option:contains(“NO”)’).prop(‘selected’,true);

regards,

···

Sam Kasozi
Information Systems Consultant
HISP Uganda | GHSI - Uganda MOH - PH Emergency Operation Center
+256 788 993565 | +256 757 662752

kasozis@gmail.com | skasozi@pheoc.go.ug | Skype: sam.kasoziug

Hi Sam,

in this case I would have used the data element type “Yes Only”. This will “default” to no / answer and present a check box. This will be equivalent to what you are doing - remember that even if you set the drop-down to No the system will not save a “No” to the database, as that requires the user to actually select No.

regards,

Lars

···

On Wed, Nov 12, 2014 at 10:55 AM, Sam Kasozi kasozis@gmail.com wrote:

Hi all,

I have data elements of value type: ‘Yes/No’ with the attributes below: What would be the custom form code for setting the default value at runtime to ‘NO’?

<select id=“bEGgpe8yxet-vwt4lpdqcbz-val” name=“vwt4lpdqcbz”

class=“ng-binding”>[Please Select]<option value=“false”

class=“ng-binding”>NO<option value=“true”

class=“ng-binding”>YES

The Jquery code below works with ordinary select fields; however, for the field above, it doesn’t seem to work.

$(select option:contains(“NO”)’).prop(‘selected’,true);

regards,

Sam Kasozi
Information Systems Consultant
HISP Uganda | GHSI - Uganda MOH - PH Emergency Operation Center
+256 788 993565 | +256 757 662752

kasozis@gmail.com | skasozi@pheoc.go.ug | Skype: sam.kasoziug


Mailing list: https://launchpad.net/~dhis2-users

Post to : dhis2-users@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-users

More help : https://help.launchpad.net/ListHelp

Hi Lars,
that would be a good alternative, however taking on that option will imply
that we will not be able to differentiate between the 'No' and 'Missing'.

regards.

Sam Kasozi
Information Systems Consultant
HISP Uganda | GHSI - Uganda MOH - PH Emergency Operation Center
+256 788 993565 | +256 757 662752
kasozis@gmail.com | skasozi@pheoc.go.ug <kasozis@gmail.com> | Skype:
sam.kasoziug

···

On Wed, Nov 12, 2014 at 2:39 PM, Lars Helge Øverland <larshelge@gmail.com> wrote:

Hi Sam,

in this case I would have used the data element type "Yes Only". This will
"default" to no / answer and present a check box. This will be equivalent
to what you are doing - remember that even if you set the drop-down to No
the system will not save a "No" to the database, as that requires the user
to actually select No.

regards,

Lars

On Wed, Nov 12, 2014 at 10:55 AM, Sam Kasozi <kasozis@gmail.com> wrote:

Hi all,

I have data elements of value type: 'Yes/No' with the attributes below:
What would be the custom form code for setting the default value at runtime
to 'NO'?

<select id="bEGgpe8yxet-vwt4lpdqcbz-val" name="vwt4lpdqcbz"
...
class="ng-binding">[Please Select]</option><option value="false"
class="ng-binding">NO</option><option value="true"
class="ng-binding">YES</option></select>

The Jquery code below works with ordinary select fields; however, for the
field above, it doesn't seem to work.

$(select option:contains("NO")').prop('selected',true);

regards,

Sam Kasozi
Information Systems Consultant
HISP Uganda | GHSI - Uganda MOH - PH Emergency Operation Center
+256 788 993565 | +256 757 662752
kasozis@gmail.com | skasozi@pheoc.go.ug <kasozis@gmail.com> | Skype:
sam.kasoziug

_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help : https://help.launchpad.net/ListHelp