Add button to display text entry field | XM Community
Skip to main content

Hi guys, 

I’ve a query wherein I’m trying to add a button which says ”Comment” so when the user clicks on it the text entry field appears to enter the comment.

 

Can I get some guidance how this can be achieved.

Thank You!

Hello @sdn , Please try with the below HTML code in HTML View:

<button id="commentButton">Comment</button>
<div id="commentField" style="display: none;">
  <textarea id="commentText" rows="4" cols="50"></textarea>
</div>

 


Thanks for the reply @Nanditha MM 

The above image represents my actual view where in the text entry field(of Qualtrics) is only displayed when the user clicks on comment button

I’m actually trying to achieve this using Javascript .Below is initial Javascript code but for some reason this doesn’t seem to work as expected

 

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/
    var questionId = 'QR~QID2';
    var commentId='comment';
     var inputElement = document.getElementById(questionId);
    var cmnt=document.getElementById(commentId);
     inputElement.hide();
    $(document).ready(function(){
     $(commentId).onclick(function(){

       inputElement.slideToggle("fast");
  });
    });

     


  

});


Leave a Reply