Anderes Item in "Combobox" auf Webseite anwählen ( <option (class, value, selected, title) ändern) - wie?

  • VB.NET

Es gibt 3 Antworten in diesem Thema. Der letzte Beitrag () ist von Vanadinit.

    Anderes Item in "Combobox" auf Webseite anwählen ( <option (class, value, selected, title) ändern) - wie?

    Sehr geehrte VB-Gemeinde, ich würde den webbrowser gern anweisen können, dass er:

    XML-Quellcode

    1. <option class="" value="157403" selected="selected" title="">NMR</option>

    in

    XML-Quellcode

    1. <option class="occupiedCities coords" value="315078" selected="selected">[44:47] Gondor</option>

    ändert (beide elemente existieren).

    Es handelt sich um eine art Dropdownbutton, der beim Anklicken mit der Maus eine Liste zeigt, in der man Einträge auswählen lassen kann.

    Der Quellcode des Navigationselements sieht so aus:

    XML-Quellcode

    1. <h3>Städtenavigation:</h3>
    2. <ul>
    3. <li><label for="citySelect">Aktuelle Stadt:</label> <select
    4. id="citySelect"
    5. class="citySelect "
    6. name="cityId" tabindex="1" onchange="this.form.submit()">
    7. <option class="" value="157403" title="" ><p>NMR</p></option><option class="" value="157861" title="" ><p>Annabergit</p></option><option class="" value="158260" title="" ><p>XRF</p></option><option class="" value="160333" title="" ><p>Titanit</p></option><option class="" value="174070" selected="selected" title="" ><p>RDX</p></option><option class="" value="184026" title="" ><p>Synchrotron</p></option><option class="" value="201466" title="" ><p>ICPMS</p></option><option class="" value="230093" title="" ><p>CL-20</p></option><option class="" value="244471" title="" ><p>PETN</p></option><option class="" value="283914" title="" ><p>Erythrin</p></option><option class="" value="312902" title="" ><p>Wolframcarbid</p></option> <option class="deployedCities coords"
    8. value="316274"
    9. >[47:48] Talisker II</option>
    10. <option class="occupiedCities coords"
    11. value="219541"
    12. >[41:43] Pittyvaich</option>
    13. <option class="occupiedCities coords"
    14. value="315078"
    15. >[44:47] Gondor</option>
    16. <option class="occupiedCities coords"
    17. value="117868"
    18. >[41:43] Roulette</option>
    19. </select></li>


    Beim ändern der Auswahl via Maus sieht das in Etwa so aus:


    Der gewählte Eintrag ist "RDX" mit der zugehörigen Nummer: "174070" und der Klasse "".

    Hat jemand eine Idee, wie ich den Webbrowser anweisen kann, die Auswahl zu ändern?

    Mit folgenden Codes ging es schonmal nicht:

    VB.NET-Quellcode

    1. Webbrowser.Document.GetElementbyID("Cityselect").InnerText = "string"
    2. Webbrowser.Document.GetElementbyID("Cityselect").InnerHTML = "string"


    Mir sind die Namen und ID nummern, sowie der Klassen der gelisteten Elemente aus dem .Document bekannt.

    Bin über jeden Tip dankbar, da schon unzählige Codingversuche fehlgeschlagen sind und mich zum verzweifeln gebracht haben.

    Dieser Beitrag wurde bereits 14 mal editiert, zuletzt von „Vanadinit“ () aus folgendem Grund: Verbesserung und Kürzung der Problembeschreibung.