# Using Javascript Functions and Demo

It is also possible to apply some style to a particular component at some particular time, by using the javascript function "SetStyleClassName(UserClassName)" to a given component.

Note: "SetStyleClassName" is available in all events and components (except for RadioButtonGroups)

As an example, we can use the following json string:

```
[
  {
    "ClassName": "TextBox",
    "Conditional": [
      {
        "Condition": "Empty",
        "HighlightFillColor": "#0000FF70",
        "HighlightStrokeColor": "#00FF00FF",
        "HighlightStrokeThickness": 10,
        "BackgroundColor": "0,255,0"
      }
    ]
  },
    {
    "ClassName": "RedBorder",
    "Conditional": [
      {
        "Condition": "Enable",
        "HighlightFillColor": "#0000FF70",
        "HighlightStrokeColor": "#FF0000FF",
        "HighlightStrokeThickness": 10,
        "BackgroundColor": "0,255,0"
      }
    ]
  }
]

```

As a result, if we set the "eform.jsonstyle" parameter to that json string:&#x20;

```
// OnStartUp event on ReportTemplate Component
This.SetReportOption("eform.stylejson", '[{"ClassName":"TextBox","Conditional":[{"Condition":"Empty","HighlightFillColor":"#0000FF70","HighlightStrokeColor":"#00FF00FF","HighlightStrokeThickness":10,"BackgroundColor":"0,255,0"}]},{"ClassName":"RedBorder","Conditional":[{"Condition":"Enable","HighlightFillColor":"#0000FF70","HighlightStrokeColor":"#FF0000FF","HighlightStrokeThickness":10,"BackgroundColor":"0,255,0"}]}]');
```

Once we render the form, all textboxes will be styles according to the "ClassName:Textbox" styling. Also, with javascript we can restyle any component by applying to it the customized "ClassName:RedBorder" styling. For example, if we want to restyle the component when clicking on a button:

```
// OnClick event of a button component
var textbox = This.GetInputComponent("textbox1");
textbox.SetStyleClassName("RedBorder");
```

## Demo

You can test the functionality with the previous configuration in the following link: \
<https://osd.forcs.com.sg/demo/eform_stylejson.html>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edu.ozeform.io/e-form-developer/design-guide/eform-input-style-configuration/using-javascript-functions-and-demo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
