Radio Button Element
The RadioButtonElement class is designed to create a radio button input element in a user interface.
Constructor
| Name | Type | Description | 
|---|---|---|
| elementId | string | This property in constructor accepts the Id for the element | 
| label | string | This property in constructor accepts the label for radio | 
| options | Array<OptionElement> | This property in constructor accepts options for radio | 
Class Usage
Here's how to create an instance of the RadioButtonElement class:
- Typescript
 
let option1 = new OptionElement("Option 1", "1");
let option2 = new OptionElement("Option 2", "2");
let optionsList = [option1, option2];
let radioButtonElement = new RadioButtonElement("1", "Choose an option", optionsList);
In this example, a new instance of RadioButtonElement is created with an elementId "1", a label "Choose an option", and a list of two options.
Key Properties and Methods
Default Value of the Input Element
The setDefaultValue() method sets the default value in the radio button input, while the getDefaultValue() retrieves it.
For example:
- Typescript
 
radioButtonElement.setDefaultValue("1");
Example
Here is an example that showcases the creation and manipulation of an instance of RadioButtonElement:
- Typescript
 
// Create some options
let option1 = new OptionElement("Option 1", "1");
let option2 = new OptionElement("Option 2", "2");
let optionsList = [option1, option2];
// Create a new instance of RadioButtonElement
let radioButtonElement = new RadioButtonElement("1", "Choose an option", optionsList);
// Set and get the default value
radioButtonElement.setDefaultValue("1");