sciter-sdk / go-sciter

Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development
https://sciter.com
2.57k stars 268 forks source link

how to add <option>Element #290

Open ying911008 opened 3 years ago

ying911008 commented 3 years ago

hello I want to add some , my code

in html : <select id="list"></select>

in go:

select, _ := root.SelectById("#list");
option, _ := sciter.CreateElement("option",  "");
err := select.Insert(option, index);
if err == nil {
  option.SetHtml("<div> HELLO </div>", sciter.SIH_REPLACE_CONTENT);
}

It can't work, how to do it?

AshfordN commented 3 years ago

I think you would need to provide more information here like: what exactly doesn't work or what do you expect versus what you actually see/encounter. Also, is there a reason you chose to do this in Go rather than script?

pravic commented 3 years ago

It's not that simple. In script, the <select> has an options property that holds the list of <option>: https://sciter.com/docs/content/behaviors/select.htm

As for the native code - there might be a problem with adding <option> directly to the list, but I am not sure.