2015-04-18 25 views
0

在Qualtrics JavaScript中,我試圖檢索先前存儲的嵌入數據,該數據的名稱末尾有一個數字以顯示在頁面上。數據存儲在result_1,result_2,result_3等。因爲有大量的結果,我想讓它與for-loop一起工作,但它不起作用。在Qualtrics中嵌入數據名稱中使用變量

我現在擁有的一切:

for (i = 0; i < 35; i++) { 
    resultText += "${e://Field/result_" + i + "}<br>" 
} 

document.getElementById("scoringCard").innerHTML = resultText; 

但是,這並不工作 - resultText返回空。 當我做手工:

for (i = 0; i < 35; i++) { 

if (i == 1){resultValue += "${e://Field/result_1}<br>"} 
else if (i == 2){resultValue += "${e://Field/result_2}<br>"} 
else if (i == 3){resultValue = "${e://Field/result_3}<br>"} 
//etc., you get the picture 
} 

document.getElementById("scoringCard").innerHTML = resultText; 

然後它的工作。但是,由於有很多結果,這使代碼非常繁瑣。任何想法如何讓它與for循環一起工作?

回答

1

不幸的是,你不能。嵌入式變量在服務器端得到解決,因此在執行JavaScript時,這些值已經修復。

相關問題