Page 1 of 1

how to select multiple items in a listbox

Posted: Mon May 31, 2010 10:42 am
by hobli
Hi,

I want to select multiple option items in a listbox with the following html code:

Code: Select all

<select myattri='cool' name="listbox" id="SelectSimple" size="4"  multiple>
    <option value="1">item 1</option>
    <option value="2" >item 2</option>
    <option value="4" selected>item 4</option>
    <option value="0">All</option>
    <option value="3" selected>  item 3  sdfasfdasdf asdf asd fasfdasd asd </option>    
</select>
When I check the tagValue of the selectTag, it always return single option selected, is it supposed to return some multiple values like "4,3"?

And the "Selected" attribute of all optionTag is always True for IE, always False for FF, I am not sure if this is a bug.

Pls advise and provide a sample if possible.

thanks a lot

Re: how to select multiple items in a listbox

Posted: Mon May 31, 2010 1:29 pm
by Support Team
Hi,
hobli wrote:When I check the tagValue of the selectTag, it always return single option selected, is it supposed to return some multiple values like "4,3"?
Sorry there is no method for SelectTag to choose multiple items. But you can use following method
//Use mehtod in main or another place
Ranorex.SelectTag selectTagSelectSimple = "YourPath";
selectMutlipleOptions1(selectTagSelectSimple.Options,1,2,3,4)

//Method
private static void selectMutlipleOptions(IList<Ranorex.OptionTag> iList, params int[] iValues)
{          	
	foreach(OptionTag opt in iList)
	{
		if (((ICollection<int>)iValues).Contains(Convert.ToInt32(opt.Value)))
		    opt.Selected = true;
	}	
}
hobli wrote:And the "Selected" attribute of all optionTag is always True for IE, always False for FF, I am not sure if this is a bug.
This is also solved with the bug you posted a few days before and will be released in next Ranorex service release.

Regards,
Peter
Ranorex Support Team

Re: how to select multiple items in a listbox

Posted: Mon May 31, 2010 2:07 pm
by hobli
thanks.

Re: how to select multiple items in a listbox

Posted: Tue Jul 06, 2010 4:39 am
by hobli
Hi,

I testing this with Ranorex 2.3.2, change optionTag's 'selected' attribute only works with IE at this moment, but not with FF 3.6.6:

selected attribute values can be changed for FF, but no visual effect on the webpage, browser still indicate the original selection status of option item.

thanks

Re: how to select multiple items in a listbox

Posted: Tue Jul 06, 2010 1:44 pm
by Support Team
Hi,

Sorry but someone forgot to implement this valueless attribute for Firefox. :oops: In the upcoming version this bug is fixed. We expect the new version (2.3.3) to be available this week.

Regards,
Peter
Ranorex Support Team

Re: how to select multiple items in a listbox

Posted: Wed Jul 07, 2010 4:13 pm
by hobli
that's fast. thanks.