Creating Radio Button and Checkbox Property Controls


This is the first post after the Tip of the Week blog’s summer hiatus.  We are back now and will start out with a series of tips related to using Text Areas to create Guided Analysis files. In this first tip back we will discuss how to create new Property Control types (radio buttons and check boxes) using a combination of Document Properties, Labels, and Scripts. While these are not truly built-in Property Controls, they do work and function properly.


In this first example we will look at building a radio button. The first thing we need to do is create two new Document Properties. One will store the value of a radio button checked and one will store the value of a radio button unchecked.  The easiest way to accomplish this is to use the Wingdings 2 font and the following symbols as the values for the property: and .

 

NOTE: you will not see the symbol right away when you enter it in the value section, this is OK.


After you add the property for the radio button checked, add a similar one called radioUnchecked which shows the symbol of an unchecked radio button.


The next step occurs in the Text Area where you want to use the radio buttons. In the location where you want each radio button displayed, you should add a Label Property Control.  In our example we will display two radio buttons in the group. One with the value yes, and one with the value no.  Each one will be on its own line, one after the other.  The screen shot below shows the Label Property Control we will add for the 'Yes' part of the radio group. The Label Property Control is attached to a new Document Property, called radioYes, which is of type string. We can leave the default value empty or we can use the unchecked radio symbol from before, :


We then add another Label on the following line in the Text Area which will show the 'No' part of the radio button group.


 
Finally we will add a script next to each label. For the first script, it will go next to the label for the 'Yes' part, and will display as a link with the display name ‘Yes’. The code is shown below:

Document.Properties["radioYes"] = Document.Properties["radioChecked"]
Document.Properties["radioNo"] = Document.Properties["radioUnchecked"]

What this is doing is setting the  radioYes property (which is attached to the 'Yes' button’s Label) to be equal to the radioChecked property (which is where the radio checked symbol is stored). Then the code sets the radioNo property (which is attached to the 'No' button’s Label) to be equal to the radioUnchecked document property (which is where the radio unchecked symbol is stored).


 
We can then add a second script with the display name No next to the No label.
 


When this is all done, you have a working radio button group in your Text Area.


  
Want to see it in action? Try it in our Training Needs Assessment Application at http://spottrain.tibco.com/SpotfireWeb/ViewAnalysis.aspx?file=kevin/TNA


Using a similar approach, you can also create a checkbox group: