✏️ Add Javascript | Getting Started Mondays | March 27th 2023 | XM Community

✏️ Add Javascript | Getting Started Mondays | March 27th 2023

✏️ Add Javascript | Getting Started Mondays | March 27th 2023
Userlevel 7
Badge +20
  • Former XM Community Team Member
  • 451 replies

What is Getting Started Mondays?

 

Every Monday we will highlight a Core XM feature, and the post will include a description of the chosen topic, a support page, and related community content. The goal of this weekly series is to help users find support pages or community posts that relate to the topic. Remember to always contact Qualtrics Support for product-related issues or urgent questions.

 

Getting Started Mondays | March 27th 2023

 

Topic: Adding Javascript

 

From adjusting the appearance of a matrix question to adding advanced functionality, adding Javascript to your Qualtrics survey allows you to customize your project to fit your needs.

The first step to adding your own custom code to your survey is knowing where to access the JavaScript editor. After doing so, you can use the XM Community's Custom Code category to search for posts that are similar to your use case, or make your own post and wait for users to help you.

Create customized & unique user experiences for your surveys and start learning how to use custom code today!

 

Where to find this feature:

  1. Click the question you’d like to add JavaScript to.

  2. In the Question behavior section, select JavaScript.

 

Support Page Links: Add Javascript

Community Post Links

Question of the Day: What was your first Javascript addition to a survey project? What Javascript code do you add most often to your questions?
 


15 replies

Userlevel 5
Badge +23

Our first Javascript used was hiding a question that converted a previous response into the format we desired.  The Javascript that we use the most is our Zip code question which determines whether the consumer is in one of our markets by looking at our location database. 

Userlevel 7
Badge +20

Our first Javascript used was hiding a question that converted a previous response into the format we desired.  The Javascript that we use the most is our Zip code question which determines whether the consumer is in one of our markets by looking at our location database. 

I was going to suggest a different way of hiding a question, until I read you used it convert a response. I’ve seen zip code questions be tackled in many different way ranging from embedded data to custom Javascript, in this case it definitely seems that custom coding is the way to go!🙂

Badge

What would suggest is the best resource for someone who wants to learn the basics of Javascript?

Userlevel 7
Badge +32

My first javascript question was to create exclusive checkbox form Opened question. Most offen JS we use is to split the value of one embedded data into multiple embedded data fields.

Userlevel 6
Badge +28

My first javascript was to hide a specific question text. I frequently use javascript to change the color code of NPS question.

Userlevel 7
Badge +20

What would suggest is the best resource for someone who wants to learn the basics of Javascript?

Hello @stacy_miller4, unfortunately, Qualtrics doesn’t offer resources to learn JavaScript. However, my suggestion would be to look at websites such as freecodeccamp or follow along with beginner JavaScript videos on YouTube.

If you are looking to understand JavaScript to use it on Qualtrics, I also recommend looking at community posts in the custom code category and practicing implementing some solutions! 

Userlevel 7
Badge +20

My first javascript question was to create exclusive checkbox form Opened question. Most offen JS we use is to split the value of one embedded data into multiple embedded data fields.

This is an interesting use case! I wouldn’t have thought to use javascript to separate embedded data into different fields. 🤔

Userlevel 7
Badge +20

My first javascript was to hide a specific question text. I frequently use javascript to change the color code of NPS question.

Yes, changing colors or any other question/survey styles is probably one of the most common use cases we see for custom JavaScript! 

Userlevel 4
Badge +16

My first JavaScript case was to turn a text question into a calendar to select the date. I don’t really know any of JS 😂 but we got the code right here in the community and it was very useful for that client back then. Currently we use it to make some calculations on dates so we can have custom dates based on dynamic criteria, like different expiration dates per country. 

Userlevel 4
Badge +16

Hey @ArunDubey 

My first javascript question was to create exclusive checkbox form Opened question. Most offen JS we use is to split the value of one embedded data into multiple embedded data fields.

I just saw a question from someone that may need something like this that you do of splitting the value of one embedded data into multiple embedded data fields here: 

Just thought that it could solve that case splitting the multi answer value and then adding up those values… If it doesn’t make sense, just ignore me haha

best regards, 

Userlevel 7
Badge +32

Hey @ArunDubey 

My first javascript question was to create exclusive checkbox form Opened question. Most offen JS we use is to split the value of one embedded data into multiple embedded data fields.

I just saw a question from someone that may need something like this that you do of splitting the value of one embedded data into multiple embedded data fields here: 

Just thought that it could solve that case splitting the multi answer value and then adding up those values… If it doesn’t make sense, just ignore me haha

best regards, 

Hi @Ricmarug , this is completely different. He can pull the code selection of each in array and can add it in one integer and then can save the total of that integer into embedded field. he will need to create embedded field for each row if he wants to get the total score of each row separately. 

Userlevel 7
Badge +32

My first javascript question was to create exclusive checkbox form Opened question. Most offen JS we use is to split the value of one embedded data into multiple embedded data fields.

This is an interesting use case! I wouldn’t have thought to use javascript to separate embedded data into different fields. 🤔

Hi @JoseS , 

We always get transport details like this, dynamically. I have just set the static value for your reference.

We need to separate the above details and saved in below variables.

JS code to separate that information on first question:

		var valX = '${e://Field/Transport_detail}'; 
var newVal =valX;
var arr1=newVal.split('|');
var arr2=arr1[1].split('-');
Qualtrics.SurveyEngine.setEmbeddedData( 'company', arr1[0] );
Qualtrics.SurveyEngine.setEmbeddedData( 'ID', arr2[0] );
Qualtrics.SurveyEngine.setEmbeddedData( 'Name', arr2[1] );
Qualtrics.SurveyEngine.setEmbeddedData( 'ID and Name', arr1[1] );
Qualtrics.SurveyEngine.setEmbeddedData( 'Mode', arr1[2] );

 

Userlevel 2
Badge +1

Hello, everyone! I am a beginner in Qualtrics. I started creating a survey for my study, and I encountered this issue:

In a block, I embedded a YouTube Video and created four thought probe questions. 

I want the video to pause and display the thought probe questions at random points and then resume automictically after displaying each question for 30s. 

Could anyone help with a JavaScript and how I could use it to achieve that?

Userlevel 7
Badge +20

Hello @m.zubeiru, I understand you have some questions regarding JavaScript.

I recommend you create your own new post to increase your request’s visibility! If you need help creating a post, please view this page. 🙂

Badge

Augusta Precious Metals is a trusted gold IRA company known for its ethical approach and excellent customer experience. Money magazine recognized it as "Best Overall Gold IRA Company" in 2022, 2023 and 2024 and Investopedia awarded it for "Most Transparent Pricing" in the same years. Augusta is committed to delivering reliable, transparent gold IRA services. The company’s A+ BBB rating, AAA from Business Consumer Alliance, and more than 1,000 five-star ratings show its dedication to superior service. Augusta offers a 100% satisfaction guarantee, industry-leading buyback guarantee and 7-day money-back guarantee for confidence and peace of mind during the account-opening process.

http://Augustapreciousmetalsreviews.com

Leave a Reply