Please help! I'm trying to write a visual basic program that makes selections on a webpage where I work. The problem that I'm having is that the webpage has several drop down selection boxes that the values in the second and third dropdowns change once the first dropdown is selected. I've written a program that will set the value of the first dropdown box but it never updated the second and 3rd dropdown boxes. I'm not sure what i'm doing wrong. It seems that a postback event is not actually being triggered.

The code i'm using is

<code>
myIE.document.all("ddModel").Value = "123SV" ' this should set the value to what i'm wanting
</code>

The website looks like this before making any selections
<code>
<select name="ddModel" onchange="__doPostBack('ddModel','')" language="javascript" id="ddModel">
<option selected="selected" value=""></option>
<option value="123SV">123SV</option>
</select>

<select name="ddNo" onchange="__doPostBack('ddNo','')" language="javascript" id="ddNo">
<option value="0">0</option>
</select>

<select name="ddSerial" onchange="__doPostBack('ddSerial','')" language="javascript" id="ddSerial">
<option value="0">0</option>
</select>
</code>

After i've made my first selection on the website it changes to look like this(if selection is made by hand, if it's made by the program it shows the correct selection in the drop down but it's not selected in the source code)
<code>
<select name="ddModel" onchange="__doPostBack('ddModel','')" language="javascript" id="ddModel">
<option value=""></option>
<option selected="selected" value="123SV">123SV</option>
</select>

<select name="ddNo" onchange="__doPostBack('ddNo','')" language="javascript" id="ddNo">
<option value="366">0</option>
<option value="349">000001</option>
<option value="206">000002</option>
<option value="249">000003</option>
</select>

<select name="ddSerial" onchange="__doPostBack('ddSerial','')" language="javascript" id="ddSerial">
<option value=""></option>
<option value="0">0</option>
<option value="1">1</option>
</select>
</code>

" language="javascript" id="ddModel"

Shouldn't you be using vbscript to be requesting help on this forum?

And what enviroment or IDE are you using to write your code?
InterDEV 6.0?

I know with InterDEV you can step through the code to debug it to see what's actually happening.

I'm writing my code in excel's visual basic. It has to interface with a website that uses javascript to do postbacks.

<code>
myIE.document.all("ddModel").Value = "123SV" ' this should set the value to what i'm wanting
</code>

Into what are you writing this code?

Looks like HTML code not Visual Basic for Applications (VBA) code.

And which library from the Tools menu are you referencing to call myIE.document.all("ddModel").Value = "123SV" Could you show how you are creating an instance (instantiating) the document object?

For example: Dim MyIE as new HtmlDocument

I originally posted this issue/problem http://www.daniweb.com/forums/thread265882.html here and got no response from it. I assumed that I was giving to much detail and that no one wanted to bother reading all of it. So after waiting quiet a while and getting no response I tried again with this more condensed version. I think if you look at the original post you'll see exactly how I define my objects etc. If not post back and i'll try to answer with more info. as for what "code" I'm writing this in it's visual basic that is in Excel. I'm not at work at the moment so I can't give you exact versions that are being run.

This code does work but the way i'm forced to make it work right now is to press a "submit" button which causes the postback to happen. The problem with that is that it causes an error because the other drop downs are not properly choosen yet. Thus I get a java popup window that I then have to use a "sendkey" method to hit enter to be returned to the first page that now has been properly updated via the postback. I'm sure there is a Better method for causing the postback than by forcing an error and having to use sendkey method but so far no one is able to even offer me a Hint of how to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.