title: Need help implementing Javascript calculation into Qualtrics
body: <p>I'm having trouble implementing this code in Qualtrics. Right now, I have created these two embedded data fields in survey flow into the block with the responses I want do calculations on: "Lambda_Block_1" and "Lambda_Mat".</p>
  
  <p>After I ask a series of questions with a matrix table, I do a page break. 
  Then my next question is a place holder/timing window. In this question, I place this Javascript:</p>
  
  <pre><code>Qualtrics.SurveyEngine.addOnload(function()
  {
  var block_1= [parseInt("${q://QID664/SelectedAnswerRecode/1}"),
    parseInt("${q://QID664/SelectedAnswerRecode/2}"),
    parseInt("${q://QID664/SelectedAnswerRecode/3}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/4}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/5}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/6}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/7}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/8}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/9}"), 
    parseInt("${q://QID664/SelectedAnswerRecode/10}")];
  
  var lambda_mat
  lambda_mat= [.7, .9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3];    
  lambda_mat.reverse();
  
    for(i=0;i&lt;lambda_mat.length;i++) {
  switchpoints[i] = switchpoints[i] * lambda_mat[i];
  }  
  var filtered_switchpoint
  filtered_switchpoint= switchpoints.filter(0);
  
  var lambda_block_1  
  if (switchpoints.allValuesSame() == true || filtered_switchpoint.length              &gt;1){
  lambda_block_1=0;
  }else{
  lambda_block_1= filtered_switchpoint;
  }
  Qualtrics.SurveyEngine.setEmbeddedData("Lambda_Block_1",lambda_block_1); 
  });
  </code></pre>
  
  <p>I need help running this in Qualtrics. 
  Does anyone have any idea why this wouldn't work? Javascript coding error?</p>