When you have a multi-select list in a web application, you may need to check which items are selected, or to check whether or not a particular item is selected. This article illustrates how to do that.

For example, say you have the following list:

<!DOCTYPE html>



<form action="form_action.asp">

<select name="cars" multiple>

  <option value="volvo">Volvo</option>

  <option value="saab">Saab</option>

  <option value="opel">Opel</option>

  <option value="audi">Audi</option>


<input type="submit">


<p>Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.</p>



Then you can use these two functions to find out which item(s) are selected. First copy the two functions into the test: GetSelectedOptionsEmbed and GetSelectedOptions. GetSelectedOptions accepts id of an HTML element that should be a 'select' element. 

    function GetSelectedOptionsEmbed(id)
        var result = "";
        var doc = null;
        if (typeof(getCurrentDocument) != "undefined")
            doc = getCurrentDocument();
            doc = document;
        var el = doc.getElementById(id);
        if (el == null)
            return id;
        for(var i = 0; i < el.childNodes.length; i++)
            var cEl = el.childNodes[i];
            if (cEl.tagName && cEl.tagName.toLowerCase() == "option" && cEl.selected == true)
                result += cEl.value + ",";   
        return result;
    function GetSelectedOptions(id)
        var script = "" + GetSelectedOptionsEmbed + "\n execResult = GetSelectedOptionsEmbed(" + JSON.stringify(id) + ");";
        script = script.replace(/[\n\r]/g, "");
        var selectedOptions = Navigator.ExecJS(script);   
        return selectedOptions;
    var select = SeS('inputSelectMultiple');
    Tester.Message("Value: " + select.GetValue());
    var options = GetSelectedOptions(select.GetId());
    Tester.Message("Selected Options: " + options);

Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 7/20/2015
  • Article ID: KB166
  • Views: 3808