1

I'm trying to extract the innertext of a selected dropdown item. The one I'm looking to return is "Institution 2"

<select name="ctl00$ContentPlaceHolder1$ddlInstName" id="ctl00_ContentPlaceHolder1_ddlInstName" style="background-color: rgb(255, 255, 128);">
        <option value="Select…">Select…</option>
        <option value="1867">Institution 1</option>
        <option selected="selected" value="719">Institution 2</option>
        <option value="1971">Institution 3</option>

This is what I have but it only returns a 0 value

account = IE.document.getElementById("ctl00_ContentPlaceHolder1_ddlInstName").getElementsByTagName("selected")(0).innerText

Any help would be greatly appreciated

0

1 Answer 1

1

Use an attribute selector for selected. It is not a tag.

ie.document.querySelector("#ctl00_ContentPlaceHolder1_ddlInstName [selected]").innerText
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.