insert text into HTML select field

I want to enter the text selection for the following select field:
<select name="Payerid" id="Payerid" class="text" name="Payerid">
		<option value="383">Aetna Healthcare</option>
                ...

Open in new window

Using VBA, I know I can use:
      IE.getElementById("Payerid").Value = "383"
but there about 100 options so I don't want to keep track of the values (which are meaningless to me) or changes the website developers make.

So is there a  way to enter the text into the select field?
I tried:
     IE.getElementById("Payerid").Text = "Aetna Healthcare"
but that didn't work.

Thanks
LVL 39
thenelsonAsked:
Who is Participating?
 
IrogSintaConnect With a Mentor Commented:
Maybe try something like this:

    Dim sOption As String
                
    For Each inp In IE.Document.getElementsByTagName("option")
        If inp.innerhtml = "Aetna Healthcare" Then
            sOption = Split(inp.outerhtml, """")(1)
            IE.getElementById("Payerid").Value = sOptionValue
            Exit For
        End If
    Next

Open in new window

Ron
0
 
thenelsonAuthor Commented:
IrogSinta,

Do you mean:
   IE.getElementById("Payerid").Value = sOptionValue
0
 
IrogSintaCommented:
Yes I did.  I'll correct it now.  Did you try that?
0
 
thenelsonAuthor Commented:
not yet
0
 
thenelsonAuthor Commented:
This works but I decided to go another direction.

Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.