Sign in to follow this  
Followers 0
PunkoHead

Get innertext of a specific value

3 posts in this topic

#1 ·  Posted (edited)

Hi Guys,

I have a dropdown in IE with values:

<option value="Chocolate"> You selected chocolate! </option>
<option value="Cheese"> You selected cheese! </option>
<option value="Oreo"> You selected oreo! </option>

I have a simple code that is selecting the item in the dropdown per value:

$user = "Cheese"
$oSelectBox = _IEGetObjByName ($oIE, "food_list")
_IEAction($oSelectBox, "focus")
_IEFormElementOptionSelect($oSelectBox, $user, 1)

What I need is to retrieve the innertext of the current selected value. So in the example above, I need it to return "You selected cheese!" in a variable $selected.

How can I do this?

Edited by PunkoHead

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try something like --

$sText = $oSelectBox.selectedOptions[0].text

This assumes that there can only be one option selected at a time.

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thanks, I got it working :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0