1
0
mirror of https://github.com/s00500/ESPUI.git synced 2025-07-04 11:20:19 +00:00

Preselect the right option in the select-input

This commit is contained in:
Christian Riggenbach
2019-03-06 00:18:19 +01:00
parent d0c59ac659
commit b987828a25
10 changed files with 19 additions and 10 deletions

View File

@ -648,6 +648,15 @@ void ESPUIClass::jsonDom( AsyncWebSocketClient* client ) {
item["parentControl"] = String( control->parentControl );
}
// special case for selects: to preselect an option, you have to add "selected" to <option>
if ( control->type == ControlType::Option ) {
if ( ESPUI.getControl( control->parentControl )->value == control->value ) {
item["selected"] = "selected";
} else {
item["selected"] = "";
}
}
items.add( item );
control = control->next;