Question T861
Visible to All Users

Change question's html property

created 7 years ago

Hello Andrew,

I'm using Showdown and I am trying to update the question's html property by using:
var question = survey.getQuestionByName("targetQuestion");
question.html = "<p>This is the new HTML title to display</p>";

but the new title just doesn't show. I have tried calling survey.render() after the previous code but the old question title still remains. What am I missing here?

Thanks!

Comments (1)

    Hello Luis,
    Is targetQuestion an html question?
    What platform do you use, angularjs as I remember?

    Thank you,
    Andrew
    SurveyJS Team

    Answers

    created 7 years ago

    Hello Serge,

    My bad! I was trying to use the html property outside of the onTextMarkdown event. Anyway, I managed to solve the problem using document.getElementById(id).innerHTML .

    Thank you and Andrew for your help!

    :Luis

      created 7 years ago

      Serge,

      I read about that but I just need to update the matrix's HTML property on demand depending on another question's answer (I'm basically adding <li></li> tags to this matrix question title based on another question's checkbox selection). It is really not related to adding/removing cells to it.

      But thanks though!

        Comments (1)

          Luis,
          In this case you may use onTextMarkdown event: https://surveyjs.io/Examples/Library/?id=survey-markdown-matrix
          You may return the title you need on your event.

          Thank you,
          Andrew
          SurveyJS Team

          created 7 years ago

          targetQuestion is a Matrix Dropdown type of question. I'm using JQuery as a platform.

          Thanks!

            Comments (1)

              Hello Luis,

              A matrix dropdown question doesn't have the html question. It should be an html question.
              In case of an html question is a cell inside of a matrix, you can get the cell question.

              You can handle the onMatrixCellCreated event and access the options.cellQuestion

              Thanks, Serge
              SurveyJS Team