PDA

View Full Version : Solved: Activating Java table with Vba



Celelond
12-10-2010, 11:25 AM
Hi all,

I have a bit of a problem I am hoping someone might have insight on.

I am writing a code to interact with a web site, this part works fine.

And one point though, I have to select an option from a drop down menu, this OnChange loads a Java Table for the next drop down menus options.

Although I am able to insert what I need in the first table, it is not activating the Java table to load the second drop down menu I need to select from.

So in code I mean
I select the first option from the drop down:
ie.document.getElementById("category").selectedIndex = 1
This works fine, except it does not seem to be picked up as a Change, and therefore when I do this next:
ie.document.getElementById("reason").selectedIndex = 9
Nothing is filled in as the java table did not load.

I have tried making the first option into a submit button and clicking it, adding a sendkeys "~" after it, and still no luck.

Please let me know if you need any other information.
The site itself I cannot link as it is a internal one.

Many thanks

Shred Dude
12-11-2010, 08:43 AM
Can you post the relevant section of the page's HTML Source?

You say you're setting the .selectedindex property, which makes me think you're dealing with an HTMLSelectElement. Have you tried to manually raise the event that would replenish the next selection box?

Maybe something like:

ie.document.getElementById("category").fireevent("onchange")

Without seeing the HTML Source it's hard to know for sure what event needs to be triggered. Is there a javascript associated with an event? If so maybe you need to submit the jscript with something like:

ie.navigate "javascript:thescriptnamehere"

Keep playing with it. You'll get it.

Shred

Norie
12-11-2010, 12:40 PM
If this really is a java applet then I don't think you'll be able to interact with it in the same way you would a webpage.

For a start you can't access the source code.

It really would help to know more about the page - it actually sounds to me as though it might be an ASP page.

The reason I think that is because sometimes a 'simple' submit won't work with a form created using ASP.

There could be other ways to try though.

Celelond
12-13-2010, 12:58 AM
It works!

Thank you so much Shred Dude. This line is what solved it for me.

ie.document.getElementById("category").fireevent("onchange")
I never knew about the fireevent until you posted this, thank you very much.

Cel