surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.12k stars 802 forks source link

How to change html table text color based on value? #7567

Closed Juuso1 closed 9 months ago

Juuso1 commented 9 months ago

Are you requesting a feature, reporting a bug or asking a question?

This is question how to change html table text color based on value in Surveyjs form? Custom function or expression?

What is the current behavior?

What is the expected behavior?

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

your_code_here

Specify your

JaneSjs commented 9 months ago

Hello @Juuso1, You can use question values in HTML question content. To use values, wrap a question or calculated value's name with curly braces.

Please consider this demo:

{
 "pages": [
  {
   "name": "page1",
   "elements": [
    {
     "type": "dropdown",
     "name": "question1",
     "defaultValue": "red",
     "choices": [
      {
       "value": "red",
       "text": "Red"
      },
      {
       "value": "orange",
       "text": "Orange"
      },
      {
       "value": "blue",
       "text": "Blue"
      }
     ]
    },
    {
     "type": "html",
     "name": "question2",
     "html": "<span style='color:{question1}'><b>Hello World</b></span>"
    }
   ]
  }
 ]
}

Let me know if you have any further questions.

Thanks