insert text into HTML select field

Posted on 2015-02-02
Last Modified: 2016-02-12
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.

Question by:thenelson
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 29

Accepted Solution

IrogSinta earned 500 total points
ID: 40584127
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

Open in new window

LVL 39

Author Comment

ID: 40584160

Do you mean:
   IE.getElementById("Payerid").Value = sOptionValue
LVL 29

Expert Comment

ID: 40585311
Yes I did.  I'll correct it now.  Did you try that?
LVL 39

Author Comment

ID: 40585427
not yet
LVL 39

Author Closing Comment

ID: 40646170
This works but I decided to go another direction.


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question