Search code examples
javascriptc#winformsscriptingcefsharp

Change select tag option in cefsharp winforms


I'm trying to change select tag options using this code in cefsharp

Browser.MainFrame.ExecuteJavaScriptAsync("document.getElementById(\"REG_CATSEQ\").selectedindex = 1;");

This is the select code

<select id="REG_CATSEQ"  name="REG_CATSEQ"  class="form-control select2">
                      <option value="">Select a value...</option>
                                                  <option value="1">تسجيل لأول مرة</option>
                                                  <option value="2">الواقعات الحياتية</option>
                                            </select>

Solution

  • Looks like you have made a typo. Both languages are case sensitive. https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement/selectedIndex

    Browser.MainFrame.ExecuteJavaScriptAsync("document.getElementById(\"REG_CATSEQ\").selectedIndex = 1;");