如何使用循环多个问题 [英] how to use loop for multiple question

查看:54
本文介绍了如何使用循环多个问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


var AppQues = document.getElementById(_ ctl1_PXP_SUN_APRSL_QSN_1,_ ctl1_PXP_SUN_APRSL_QSN_2,ctl1_PXP_SUN_APRSL_QSN_3,ctl1_PXP_SUN_APRSL_QSN_4);



var AppQues = document.getElementById("_ctl1_PXP_SUN_APRSL_QSN_1", "_ctl1_PXP_SUN_APRSL_QSN_2", "ctl1_PXP_SUN_APRSL_QSN_3", "ctl1_PXP_SUN_APRSL_QSN_4");

AppQuest(AppQues, lang);







function AppQuest(ddl,lang) {

          if (lang.toLowerCase() == "de-de")


           {
               for (var i = 1; i < 5; i++) {
                   if (document.getElementById("_ctl1:PXP__APRSL_QSN_" + i).value == "") {
                       document.getElementById("_ctl1:PXP__APRSL_QSN_" + i).value = ["Ja", "Nein"];
                   }

               }
           }










my requirement is i have 5 question and 5 dropdownbox , and default value is "yes", "no".
 
but when language id german its change to "ja","nein" .
 
iam using for loop to achive this, but gives error: object required.
 
please guide to rectify the code,
 
thx in advance.

推荐答案

你应该动态地从你的键字符串构建你的最后一部分,就像在下一个例子中一样:

You should build your last part from your key string dynamically like in the next example:
for( var  i = 1; i<4;i++)
{
 var uiElement=document.getElementById("_ctl1:PXP__APRSL_QSN_" + i);
 if (uiElement && uiElement.value == "") {
         uiElement.value = "Yes";
     }

}


这篇关于如何使用循环多个问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆