showing/hiding textarea based on radio button selection

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

showing/hiding textarea based on radio button selection

ilango_g
Hi
I have an XForn with a dropdown, two radio buttons and two text areas. On selecting the first radio button, I would like the first text area (the one with no label on it) to be hidden. (because it is not relevant for this selection). On the Xform being initially loaded, this textarea can stay invisible.
If the second radio button is selected, this text area should appear because it is relevant to that. But right now, I see that even when I select the second radio button the textarea remains hidden.

My solution to hide the text area was to put a bind on the textarea based on an expression in the "relevant" attribute that makes the textarea relevant if the selection on the radio buttons is equal to a certain string.

I have enclosed a small test case that runs in the sandbox.

thanks in advance.

view.xhtml
Reply | Threaded
Open this post in threaded view
|

Re: showing/hiding textarea based on radio button selection

fl.schmitt(ops-users)
hi someperson,

> If the second radio button is selected, this text area should appear because
> it is relevant to that. But right now, I see that even when I select the
> second radio button the textarea remains hidden.

the problem is that the relevance test will _always_ fail. For the comparison
the node
        instance('radios')/fe:radio_button_affadavit

is used, but this node doesn't exist, so the string comparison will fail in
every case. Instead, you have to reference the following node:

        instance('taskoutput')/fe:select_one_of_two_radio_buttons

With this change, the textarea will show and hide depending on the radio button
selection.

Some other points i found that may cause problems:

- Line 179-181: the first of the two texareas contains a bind and a ref
attribute. If i understand the xforms specs correctly, the ref attribute has no
effect in this case. It's sufficient to reference the binding using bind because
  the node reference definde in the xforms:bind elementwill be used. So you
could eigther set aside the ref or the bind attribute.

- Line 151: the combobox references the input instance, but i suppose it should
set the value of the corresponding node in the taskoutput instance. If you
change this, you will have to change the nodeset reference explicitly to the
taskinput instance.

- Line 83: the setvalue command will set the taskoutput value to the maybe
unwanted value "1 Arraignment Court 1 Arraignment Court 2 Act 33 Case 2 Act 33
Case 3 Pittsburg Magistrate Court 3 Pittsburg Magistrate Court 4 Tara Smith 4
Tara Smith" - i suppose you intend to set it to the first selectable value. Then
you will have to take the value from the node

        instance('taskinput')/fe:am/fe:magistrate[1]/fe:identfier

- generally, it would make the xforms more clear to use a <xforms:group
ref="instance('taskoutput')"> around the controls so only the references to
nodes in other instances have to be declared using the instance() function.


HTH
florian


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: showing/hiding textarea based on radio button selection

ilango_g
Thanks very much. I incorporated fe:select_one_of_two_radio_buttons into my bind and it worked.

And I will address all those issues you have pointed out.



fs(ops-users) wrote
hi someperson,

> If the second radio button is selected, this text area should appear because
> it is relevant to that. But right now, I see that even when I select the
> second radio button the textarea remains hidden.

the problem is that the relevance test will _always_ fail. For the comparison
the node
        instance('radios')/fe:radio_button_affadavit

is used, but this node doesn't exist, so the string comparison will fail in
every case. Instead, you have to reference the following node:

        instance('taskoutput')/fe:select_one_of_two_radio_buttons

With this change, the textarea will show and hide depending on the radio button
selection.

Some other points i found that may cause problems:

- Line 179-181: the first of the two texareas contains a bind and a ref
attribute. If i understand the xforms specs correctly, the ref attribute has no
effect in this case. It's sufficient to reference the binding using bind because
  the node reference definde in the xforms:bind elementwill be used. So you
could eigther set aside the ref or the bind attribute.

- Line 151: the combobox references the input instance, but i suppose it should
set the value of the corresponding node in the taskoutput instance. If you
change this, you will have to change the nodeset reference explicitly to the
taskinput instance.

- Line 83: the setvalue command will set the taskoutput value to the maybe
unwanted value "1 Arraignment Court 1 Arraignment Court 2 Act 33 Case 2 Act 33
Case 3 Pittsburg Magistrate Court 3 Pittsburg Magistrate Court 4 Tara Smith 4
Tara Smith" - i suppose you intend to set it to the first selectable value. Then
you will have to take the value from the node

        instance('taskinput')/fe:am/fe:magistrate[1]/fe:identfier

- generally, it would make the xforms more clear to use a <xforms:group
ref="instance('taskoutput')"> around the controls so only the references to
nodes in other instances have to be declared using the instance() function.


HTH
florian


--
You receive this message as a subscriber of the ops-users@ow2.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@ow2.org
For general help: mailto:sympa@ow2.org?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws