# Select

Select components are used for collecting user provided information from a list of options.

## Simple Select

Create a simple select with multiple options.

![](https://1373299915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8F6PrkNTG8Y34hADzKOL%2Fuploads%2Fgit-blob-c115dcc65b57415dd528a35439397f8f2d20d1a2%2Fimage%20\(309\).png?alt=media)

```powershell
New-UDSelect -Option {
    New-UDSelectOption -Name 'One' -Value 1
    New-UDSelectOption -Name 'Two' -Value 2
    New-UDSelectOption -Name 'Three' -Value 3
}
```

## Grouped Select

Create a select with groups of selections.

![](https://1373299915-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F8F6PrkNTG8Y34hADzKOL%2Fuploads%2Fgit-blob-541344341997e8e59c1a9dc7f0a068c60b6c9736%2Fimage%20\(283\).png?alt=media)

```powershell
New-UDSelect -Option {
    New-UDSelectGroup -Name 'Group One' -Option {
        New-UDSelectOption -Name 'One' -Value 1
        New-UDSelectOption -Name 'Two' -Value 2
        New-UDSelectOption -Name 'Three' -Value 3
    }
    New-UDSelectGroup -Name 'Group Two' -Option {
        New-UDSelectOption -Name 'Four' -Value 4
        New-UDSelectOption -Name 'Five' -Value 5
        New-UDSelectOption -Name 'Size' -Value 6
    }
}
```

## OnChange

Execute a PowerShell event handler when the value of the select is changed. $EventData\[0] for the single item that was selected.

```powershell
New-UDSelect -Option {
    New-UDSelectOption -Name 'One' -Value 1
    New-UDSelectOption -Name 'Two' -Value 2
    New-UDSelectOption -Name 'Three' -Value 3
} -OnChange { Show-UDToast -Message $EventData[0] }
```

## Multiple Select

Execute a PowerShell event handler when the more than one value of the select is changed. $EventData is an array of the selected items.

```powershell
New-UDSelect -Multiple -Option {
    New-UDSelectOption -Name 'One' -Value 1
    New-UDSelectOption -Name 'Two' -Value 2
    New-UDSelectOption -Name 'Three' -Value 3
} -OnChange { 
    Show-UDToast -Message (ConvertTo-json -InputObject $EventData) 
}
```

## Get-UDElement

Retrieve the value of the select from another component.

```powershell
  New-UDSelect -Option {
      New-UDSelectOption -Name 'One' -Value 1
      New-UDSelectOption -Name 'Two' -Value 2
      New-UDSelectOption -Name 'Three' -Value 3
  } -Id 'select' -DefaultValue 2

  New-UDButton  -Text 'OnBoard' -OnClick {
    $Element = Get-UDElement -Id 'select'
    if ($Element.Value)
    {
      Show-UDToast -Message $Element.Value
    }
    else 
    {
      Show-UDToast -Message $Element.DefaultValue
    }
  }
```

## API

* [New-UDSelect](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDSelect.txt)
* [New-UDSelectOption](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDSelectOption.txt)
* [New-UDSelectGroup](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDSelectGroup.txt)

***

###


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.powershelluniversal.com/apps/components/inputs/select.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
