Solved

insert text into HTML select field

Posted on 2015-02-02
5
69 Views
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.

Thanks
0
Comment
Question by:thenelson
  • 3
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
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
    Next

Open in new window

Ron
0
 
LVL 39

Author Comment

by:thenelson
ID: 40584160
IrogSinta,

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

Expert Comment

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

Author Comment

by:thenelson
ID: 40585427
not yet
0
 
LVL 39

Author Closing Comment

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

Thanks
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Find out what you should include to make the best professional email signature for your organization.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now