Forum Discussion

SSharma3's avatar
SSharma3
Occasional Contributor
3 years ago

Not able to select the item in the combo box

Hi,

I have one combo box, I am using this logic to select the item in the combo box.

value is the name of the combo box item.

 

Sometimes, the item gets selected. But other times only the first item is getting selected. What can be the possible;e reason for that?

 

for (var index=0;index<reqObj["wItemCount"];index++)
{
if(reqObj["Items"]["Item"](index)["Name"]==value)
reqObj["ClickItem"](index);
}

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I think your coding should look like this,

    for (var index = 0; index < reqObj["wItemCount"]; index++)
    {
        if (reqObj["Items"]["Item"](index)["Name"] == value)
        {
            var objItem = reqObj["Items"]["Item"](index)["Name"];
            objItem["ClickItem"]();
        }
    }