Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

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);


C#
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.
Posted
Updated 20-Mar-14 23:45pm
v2

1 solution

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";
     }

}
 
Share this answer
 
v2
Comments
Master Vinu 21-Mar-14 3:29am    
var AppQues = document.getElementById["_ctl1_PXP_SUN_APRSL_QSN_1", _ctl1_PXP_SUN_APRSL_QSN_2", "ctl1_PXP_SUN_APRSL_QSN_3"];

AppQuest(AppQues, lang);

function AppQuest(ddl,lang) {

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


{
for (i = 1; i < ApprQues.length; i++)
{ var ddlVal = ["Ja", "Nein"]; }
}

}

raul@ m trying above code please let me whats wrong in that
thx in advance
Nirav Prabtani 21-Mar-14 3:31am    
my 5+
Master Vinu 21-Mar-14 3:32am    
please leet me know its perfect or not?
Nirav Prabtani 21-Mar-14 3:35am    
try Raul Iloc's Solution it is perfect..
Master Vinu 21-Mar-14 4:13am    
raul@ pls confirm the code

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";
}

}
}

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900