Is there anyway to create a radio button dynamically?

Hi all,

Just wonder is there anyway to create a radio button dynamically, that is, based on an integer field, if the field return 3, then create 3 radio button, if 4, then create 4 radio button.

Thank you very much.

Subject: Is there anyway to create a radio button dynamically?

Hi Abu,

You could use ComputedText on your Form, with some formula. If condition = x, then the result could be the HTML for your radio button field.

I suppose then you’d need some Javascript on the OnChange event of your integer field, which would force the ComputedText to be computed again.

Let me know if this helps.

Subject: RE: Is there anyway to create a radio button dynamically?

Sorry, i don’t quite understand, can you explain a little bit more?

thanks

Subject: RE: Is there anyway to create a radio button dynamically?

Hi Abu,

There are a number of ways to do it - I assume this is for web browser use?

The easiest way is to have a dialog list field called, say, “Number” which holds the options 0,1,2,3.

Then you can selectively hide your radio buttons depending on which you choose in this field. To make this work you need to set the Option “Refresh Fields On Keyword Change” on your Dialog List field. Once you’ve done this, the Form will automatically refresh each time you choose a value in the Dialog List.

Then you have three rows of Pass-Thru HTML containing the HTML for each of your Radio Buttons. Something like the following:



Radio Button 1

Radio Button 2

Radio Button 3

Like I say, each radio button needs to be on a different row on the form, so that you can apply Hide-When formulas to each separately.

Then for the first Radio, assuming you want it to appear if the user chooses at least 1, the hide-when formula would be as follows:

@If(Number=“0”)

This will hide radio button 1 if 0 is selected.

Then for the second one you’d use:

@If(Number=“0” | Number=“1”)

Now your 2nd radio button only appears if at least “2” is selected in your dialog list field.

And so on for as many radio buttons as you like…

Hope this helps.

Subject: In the client, do it this way?

On the properties box for the radio button field, on the second tab, change “Enter choices (one per line)” to “Use formula for choices”. Then in the space for the formula enter an appropriate formula such as:

choices := “Choice1” : “Choice2” : “Choice3” : “Choice4”;

@Subset(choices; IntegerField)

Obviously, the formula can get as elaborate as needed.