Encosed Sample code … Works fine but …
If you do not select/deselect a value but first click on button, the selected value is empty
would expect to get the values with “-selected” …
$global:mypage = New-UDPage -ID mypage -Name “mypage” -Endpoint {
# Input usualy from Database ...
$dbs=@()
$myrow = @{
name = 'Row1'
number = '1'
}
$dbs=$dbs+$myrow
$myrow = @{
name = 'Row2'
number = '2'
}
$dbs=$dbs+$myrow
$myrow = @{
name = 'Row3'
number = '3'
}
$dbs=$dbs+$myrow
# Card
New-UDCard -Content {
# Select
New-UDSelect -ID myselect -MultiSelect -Label ‘select me’ -Option {
foreach ( $value in $dbs ) {
New-UDSelectOption -Name $value.name -Value $value.number -Selected
}
}
# Button
New-UDButton -Icon ticket -Text "Button" -OnClick {
$myvar=get-UDElement -id myselect
$myvar=$myvar.Attributes['value']
Show-UDToast -Message "> $myvar <" -Duration 2000
}
}
}
$Dashboard = New-UDDashboard -Title “Multiselect” -Page $global:mypage
Get-UDDashboard | Stop-UDDashboard
Start-UDDashboard -Dashboard $Dashboard -Port 10000 -AllowHttpForLogin