Results 1 to 2 of 2

Thread: Using Visual Basic/Javascript together in WebBrowser

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    2

    Using Visual Basic/Javascript together in WebBrowser

    Hi,

    I describe my problem in depth below but the short-winded version is......Does anyone know of a way when using the webbrowser control to let visual basic code (VB 6) call a javascript function already contained in the webpage?

    Thanks.

    Now for the long-winded version.....
    I have a problem which I'm hoping someone can help me solve or let me know if it is impossible. Using VB 6, I created an application that uses the Webbrowser control to load a webpage. The webpage consists of 10 combo-boxes, each one having 25 values in. Usually, a user selects a value in the combobox and, via javascript and the onClick command, the new value in the combobox is automatically sent via the submit() function to a server. What I'm trying to do is automate this behavior via VB so that once the webpage loads, my program will access each one of the comboboxes, choose a value, and have that value sent to the server.

    I have been able to programmatically access the combo boxes and change the values in them. However, the onClick command is not sent when the value is changed thru my VB code (even if I send a cmbBox.click event), thus the submit() javascript function is not called and the answers are not sent or saved on the server. I have tried a number of ways to solve this problem, but to no avail. My last hope is that somehow I can call the javascript submit function that saves to the server using visual basic. Here is the javascript function I'd like to call:

    function answer(number, anser) {
    frmName.answer.value=ans
    frmName.submit()
    }

    Thanks.

  2. #2
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    I have not done it myself, but if memory serves correct, I think the HTML DOM has methods to execute script functions. Look on MSDN for the script element.... It should have all the methods you can execute in there... It should have a method to dynamically execute a function in the script block (I'm guessing).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width