jQuery/Javascript Default Choices for Dropdown in Qualtrics


I have the following side-by-side question in Qualtrics.

<a href="https://i.stack.imgur.com/pgZcy.jpg" rel="nofollow">Picture of question</a>

The dropdown menu in has the same four statements as presented in the Statement Choices and 'Dummy Column'. I am trying to get the default choice for the dropdown to be the value in the 'Dummy Column'.

Using the following code, I can get the dropdown value to equal the Statement Choice column:

// Default Choice var $embedded = []; var $length = $jq(".SBS2 select").length; for (var i=0;i<$length-1;i++) { $embedded[i] = $jq(".Choice .c1").eq(i).text().trim(); $jq(".SBS2 select").eq(i).find('option:contains(' +$embedded[i]+ ')').attr('selected','selected'); } $jq('.SBS1').hide(); / Hide Dummy Column/

I am struggling to update the code to pick up the value in 'Dummy Column' instead. I have tried updating ".Choice .c1" to ".SBS1 input" but it just selects the last value in the dropdown list for all rows.

Can someone help with what I am doing wrong?

Thanks in advance


Two things: 1. Your values are in text input fields, so you need to get the values of those fields. 2. Your selector needs to find the text input fields, so '.SBS1 input' is correct.

Thus, change your $embedded[i] = line of code to this:

$embedded[i] = $jq(".SBS1 input").eq(i).val().trim();

It seems you are doing it the hard way though. Why not just pipe your default values into the $embedded array to being with instead of creating a dummy column that you then have to hide?

var $embedded = ["${e://Field/ed1}".trim(), "${e://Field/ed2}".trim(), etc. ]

You could then delete the $embedded[i] = line altogether.

P.S. This isn't PHP where you need $ in front of variables...it actually makes it a bit confusing at first glance. Also, no need to assign jQuery to a variable, just use jQuery.


  • JQuery autocomplete return a checkbox checked
  • Duplicate output looping through multiple values in while loop bash
  • How to set crop box in jquery cropper
  • Use STL find_if() to find a specific object in a Vector of object pointers
  • Can sklearn DecisionTreeClassifier truly work with categorical data?
  • Call knockout viewmodel function in jQuery
  • SQL database problems with addressbook table design
  • How to multiply.outer() in NumPy while assuming 0 * infinity = 0?
  • Spark scala: SELECT in a foreach loop returns java.lang.NullPointerException
  • Generating and downloading an excel file generates a ERR_INVALID_RESPONSE
  • PostgreSQL: update with left outer self join ignored
  • Get value of last non-NA row per column in data.table
  • Parsing Complex JSON file with JQ Issue
  • What is the difference in Angular2 between inject a provider in @Component and @Module?
  • Replace Inf in R data.table / Show number of Inf in colums
  • JOOQ nested condition
  • addressing in assembler
  • Inversing an interpolation of rotation
  • joining two bezier curves
  • How to access culture data in globalize.js V1.0.0
  • Implementation of State Monad
  • Spray.io: When (not) to use non-blocking route handling?
  • Modifying destination and filename of gulp-svg-sprite
  • Font Awesome Showing Box instead of Icons
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • GridView Sorting works once only
  • retrieve vertices with no linked edge in arangodb
  • using HTMLImports.whenReady not working in chrome
  • How do you join a server to an Active Directory (domain)?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • Authorize attributes not working in MVC 4
  • apache spark aggregate function using min value
  • EntityFramework adding new object to nested object collection
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal