I am creating a question on how much people spend on a product.
This is how I’d like the question to behave:
The “£” sign and “per year” should be fixed either side of the text box, but a standard text box question type doesn’t seem to allow that. Is there a way around this?
Thank you for your help!
Zoe
Page 1 / 1
@ZoeRobo
Try and add the below JS on the text entry question.
Qualtrics.SurveyEngine.addOnload(function() { /*Place Your Javascript Below This Line*/ jQuery("#" + this.questionId + " .InputText").css('width','80%') //adjust accordingly var inputs = $(this.getQuestionContainer()).select('inputttype="text"]'); for (var i = 0; i < inputs.length; i++) { var input = inputssi]; $(input).insert({before: '£ '}); $(input).insert({after: ' per year'}); }
});
Hope it helps!
Hi @ZoeRobo Create a text graphic question and insert this code in the HTML view of the question text.
<div class="spending-question"> <span class="currency-symbol">Approximately how much do spend per year on the products?</span></div><div class="spending-question"><span class="currency-symbol"><br>£</span> <input class="amount-input" type="text"> <span class="per-year">per year</span> </div>
Thank you @Deepak and @omkarkewat - I will take a look at this now
You help is much appreciated!
Thank you! Works perfectly!
@ZoeRobo
The HTML @omkarkewat has provided would not capture the answer provided by respondent.
Hence, kindly take that into consideration.
Hello @Deepak , I see I was too hasty, my apologies. I can see that your solution enables capturing the answer to the survey. Thank you for pointing that out. I am not sure how to change “best answer” - hopefully I haven’t caused a problem..
@ZoeRobo
That’s okay!
@AmaraW can help here.
Hi @Deepak , again apologies. I am running into trouble with your solution…
I have select “text entry” question.
I have selected the </> JavaScript button with that question selected. then I cut and paste your code into the window.
However, when I go to preview, there is no text box or “£” or “per year” - what am I doing wrong?
thank you!
@ZoeRobo
try checking if any other code is overriding this or try creating new question. As the code does work.
Yes! it works… I think it wasn’t displaying properly because of a bookmark I had set up in preview.
Thank you @Deepak ! I will pick up with @AmaraW the other thing.