I am a noob - Trouble setting textbox with button click

Hey There, I am new to Universal and I am still trying to get my bearings :slightly_smiling_face:

I am trying to put together some dashboards and I am working on setting controls from other controls. Here is my code - very simple but I cannot seem to get the TextBox to update with the button click. I have tried Set-UDElement with both attributes and content. I am hoping someone can tell me what I am doing wrong… Thanks!

New-UDDashboard -Title “Hello, World!” -Content {

New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'

New-UDButton -OnClick {

    Set-UDElement -Id 'txtExample' -Content {"this is a test..."} 

     <# Set-UDElement -Id 'txtExample' -Attributes @{

        type = "text"

        value = "bh"

    } #> 

} -Text "Get textbox value"

}

You can do it this way:

New-UDDashboard -Title 'Test' -Content {
    New-UDTextbox -Id 'txtExample' -Label 'Label' -Value 'Value'

    New-UDButton -OnClick {

        Set-UDElement -Id 'txtExample' -Properties @{
            Value = "test123"
        }

    } -Text "Get textbox value"
}

(This is on UD 1.3, V3)

Not meaning to hijack another thread, but same topic, just want to see if we found another bug… when I do that in my code, it updates the field, but doesn’t focus it so that the label moves over the item.

$TheCostCenter = $Cache:CostCenterMap | Where-Object Office -eq $TheLocation | Select-Object CostCenter
Set-UDElement -Id ‘txtCostCenter’ -Properties @{value = $TheCostCenter.CostCenter}
Sync-UDElement -ID ‘txtCostCenter’

image

When I click inside the box, it moves properly…

image

Move out… goes back to “overwrite” mode.

Thanks!

Weird. Seems like a bug. It’s funny because I remember having this issue on previous versions of UD but it has snuck back in there.

Thanks Adam - I appreciate the quick response! Worked great!