Link to home
Start Free TrialLog in
Avatar of busycoder
busycoder

asked on

I need to call the onchange event after setting the value of a select - option html object in a page

I am using FoxPro to do some automation of an external Internet explorer page. I can set the value just fine, but can't seem to get the page to run whatever code it wants to that in this case makes visible another select - option pick list to choose from.

The event seems to be the onchange event, but I can't seem to call it properly to get it to work.

ie.Document.getElementsByTagName('select').[1].value='somevalue'

Open in new window

Avatar of tusharkanvinde
tusharkanvinde
Flag of India image

Are you changing the value of the 1st OPTION of the SELECT or are you changing the selection. The OnChange should run when you change the selection, not when you change the value of the 1st OPTION.
Avatar of busycoder
busycoder

ASKER

Here is the html code for an example page.

<select onchange="alert('Changed')">
      <option value="one" >One</option>
      <option value="two" >Two</option>
      <option value="three" >Three</option>
</select>

Here is the foxpro line that successfully changes the value, but does not fire the onchange event:

ie.Document.getElementsByTagName('select').[0].value='two'  

Since not all selects that I run into have a name it has to be called this way.





SOLUTION
Avatar of tusharkanvinde
tusharkanvinde
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Really helped me out, thanks guys for troubleshooting this and giviing me the solution.