# Add a pop-up message to prompt the CHV to ask further question or give more information or provide health education

**URL:** <https://forum.communityhealthtoolkit.org/t/add-a-pop-up-message-to-prompt-the-chv-to-ask-further-question-or-give-more-information-or-provide-health-education/2734>\
**Category:** Design\
**Tags:** ui-ux, workflow\
**Created:** [May 9, 2023, 4:23pm UTC](https://forum.communityhealthtoolkit.org/t/add-a-pop-up-message-to-prompt-the-chv-to-ask-further-question-or-give-more-information-or-provide-health-education/2734 "2023-05-09T16:23:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jkuester](https://communityhealthtoolkit.b-cdn.net/user_avatar/forum.communityhealthtoolkit.org/jkuester/32/806_2.png) [@jkuester](https://forum.communityhealthtoolkit.org/u/jkuester)\
**Post date:** [June 14, 2023, 9:39pm UTC](https://forum.communityhealthtoolkit.org/t/add-a-pop-up-message-to-prompt-the-chv-to-ask-further-question-or-give-more-information-or-provide-health-education/2734/2 "2023-06-14T21:39:33Z")

</div>

So, I do not believe there is a built-in way to pop up a message/prompt when filling out a form. However, I have confirmed that it is possible to achieve behavior similar to what you are proposing with a custom [extension-lib](https://docs.communityhealthtoolkit.org/apps/reference/forms/app/#chtextension-lib). Basically the idea is to create a custom `extension-lib` function that allows for opening an alert from the browser/app.

Example:

Create a new [extension library](https://docs.communityhealthtoolkit.org/apps/reference/extension-libs/) with the following code:

```js
const getValue = function(obj) {
  let val;
  if (obj.t === 'arr') {
    val = obj.v && obj.v.length && obj.v[0];
  } else {
    
    val = obj.v;
  }
  if (!val) {
    return '';
  }
  return val.textContent;
};

module.exports = function(first) {
  const message = getValue(first);
  window.alert(message);
  return first;
};

```

Then you can use the extension-lib function in a form like this:

| type | name | label::en | relevant | appearance | calculation |
| --- | --- | --- | --- | --- | --- |
| begin group | page | NO\_LABEL | | field-list | |
| string | message | Enter alert message | | | |
| trigger | show | Show Alert? | | | |
| calculate | alert | | ${show} = “OK” | | cht:extension-lib(“alert.js”, …/message) |
| end group | page | | | | |

This will cause the alert to be opened whenever the `alert` field becomes relevant. (Also, you could use `window.confirm` in the extension function instead if you want to record a boolean value of the user’s response to the alert.)

This would work for brief notification messages, but is probably not ideal for long-form documentation. For that it would be nice to have a more sophisticated approach. Several issues have been logged recently that would provide interesting options here:

> <https://github.com/medic/cht-core/issues/8217>
>
> \[Guidance hints\](https://xlsform.org/en/#guidance-hints) are collapsible (and co…llapsed by default) hint texts that can be added to questions in a form. Normal hints are always displayed and so are always taking up screen space. This is not great for extensive information that might not always need to be referenced but still is important to have available to the user. Reference information could be embedded in a guidance hint that the user could reference when needed, but otherwise would not affect their workflow (they would not have to scroll past a bunch of text they are not going to read....).  
> 
> These guidance hints are already supported in enketo-core \`5.5.2\`+ so cht-core 4.x technically already has built-in support. However, our verison of \[pyxform\](https://github.com/medic/pyxform) does not support including these in the form xml when converting the xlsx. So, that would need to be upgraded to be able to use the functionality. Also, cht-core needs a new translation and probably some css tweaking to make stuff look nice.  
> 
> I kinda manually compiled an xml for a form with a guidance hint and loaded into the CHT and this is what it looks like currently:
> 
> !\[image\](https://user-images.githubusercontent.com/8441903/236497325-a0cc6aaf-2958-4ca5-8622-2712dc226804.png)
> !\[image\](https://user-images.githubusercontent.com/8441903/236497350-043d923c-6ac4-4c54-b0a8-927236ebdab2.png)
> 
> \`\`\`.xml
> \<?xml version="1.0"?\>
> \<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms"\>
> \<h:head\>
> \<h:title\>Enketo Widgets\</h:title\>
> \<model\>
> \<itext\>
> \<translation default="true()" lang="en"\>
> \<text id="/enketo\_widgets/my\_group/name:hint"\>
> \<value form="guidance"\>This is a guidance hint!\</value\>
> \</text\>
> \</translation\>
> \</itext\>
> \<instance\>
> \<enketo\_widgets id="enketo\_widgets" prefix="J1!enketo\_widgets!" delimiter="#" version="2023-05-05 00:00:00"\>
> \<my\_group\>
> \<age/\>
> \<name/\>
> \</my\_group\>
> \<meta tag="hidden"\>
> \<instanceID/\>
> \</meta\>
> \</enketo\_widgets\>
> \</instance\>
> \<instance id="contact-summary"/\>
> \<bind nodeset="/enketo\_widgets/my\_group/age" type="string"/\>
> \<bind nodeset="/enketo\_widgets/my\_group/name" type="string"/\>
> \<bind nodeset="/enketo\_widgets/meta/instanceID" type="string" readonly="true()" calculate="concat('uuid:', uuid())"/\>
> \</model\>
> \</h:head\>
> \<h:body class="pages"\>
> \<group appearance="field-list" ref="/enketo\_widgets/my\_group"\>
> \<input ref="/enketo\_widgets/my\_group/age"\>
> \<label\>Age?\</label\>
> \<hint\>this is a regular hint\</hint\>
> \</input\>
> \<input ref="/enketo\_widgets/my\_group/name"\>
> \<label\>Name?\</label\>
> \<hint ref="jr:itext('/enketo\_widgets/my\_group/name:hint')"/\>
> \</input\>
> \</group\>
> \</h:body\>
> \</h:html\>
> \`\`\`

> <https://github.com/medic/cht-core/issues/8218>
>
> Currently there is no way to show/hide sections of a form except via \`relevant\` …logic. This does not work for all use-cases since values in the non-relevant part of the form will not be saved at the end.
> 
> The default Enekto webapp supports being able to just collapse groups (that do not have the \`field-list\` appearance).  
> 
> !\[image\](https://user-images.githubusercontent.com/8441903/236499737-6fc095b4-d9c1-422f-9333-23528346360e.png)
> !\[image\](https://user-images.githubusercontent.com/8441903/236499821-dc413d6a-0a13-4dc4-be52-992158ab1640.png)
> 
> We could support similar functionality in the CHT, though we may want to make it opt-in. So if you added the \`collapsible\` appearance to a group it would make this happen. (Also would be good to consider some way of making the group collapsed by default, when desired, so the content is initially hidden until the user expands the group....)

---

_[View the full topic](https://forum.communityhealthtoolkit.org/t/add-a-pop-up-message-to-prompt-the-chv-to-ask-further-question-or-give-more-information-or-provide-health-education/2734)._
