dcsimg
Results 1 to 7 of 7

Thread: automate onchange event with javascript...

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2019
    Posts
    2

    automate onchange event with javascript...

    hi, I have a problem, I have to simulate a click on a corporate web page in a drop-down menu, to enable a second drop-down menu. I can not make it...
    here is part of the vb code

    Code:
     URL = "http://2k3-portalesed/sed/grafici/Attivita/Gestione_Attivita.aspx"
    
            objIE = Nothing
    
            If objIE Is Nothing Then
                objIE = GetObject("new:{D5E8041D-920F-45e9-B8FB-B1DEB82C6E5E}")
            End If
    
    
    
            objIE.Visible = True
            objIE.Navigate(URL)
            objIE.Width = 1000
            objIE.Height = 600
    
    
            Do Until objIE.ReadyState = 4
    
                System.Windows.Forms.Application.DoEvents()
    
            Loop
    
            With objIE
                .Document.getelementbyid("txtIdLinea").setattribute("value", (txtIdLinea))
                .Document.getelementbyid("txtCodClienteFinale").setattribute("value", (txtCodClienteFinale))
                .Document.getelementbyid("txtProgetto").setattribute("value", (txtProgetto))
                .Document.getelementbyid("ddlCarrier").setattribute("value", (ddlCarrier))
                .Document.getelementbyid("txtTecnicoIntervenuto").setattribute("value", (txtTecnicoIntervenuto))
                .Document.getelementbyid("ddlEsito").setattribute("value", (ddlEsito))
                .Document.getelementbyid("ddlDurataNew").setattribute("value", (ddlDurataNew))
                .Document.getelementbyid("txt_Committente").setattribute("value", (txt_Committente))
                .Document.getelementbyid("ddl_Tipologia").setattribute("value", (ddl_Tipologia))
                ' .Document.getelementbyid("ddl_Tipologia").setattribute("selected", CStr(True))

    there is an associated script but I can't simulate the click

    HTML Code:
       <select name="ddl_Tipologia" onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;ddl_Tipologia\&#39;,\&#39;\&#39;)&#39;, 0)" id="ddl_Tipologia" class="testo_normale">
    	<option value="0"></option>
    	<option value="6">ATTIVITA&#39; DI INGEGNERIA</option>
    	<option value="1">CONTROLLI IN PROATTIVITA&#39;</option>
    	<option selected="selected" value="3">SUPPORTO TECNICO SPECIALISTICO</option>
    	<option value="4">TICKET PSS</option>
    
    </select>
                        <span id="rfv_ddl_Tipologia" class="error" style="color:Red;display:none;"></span>
                        
                        <select name="ddl_Tipologia_dett" id="ddl_Tipologia_dett" class="testo_normale">
    	<option value="0"></option>
    	<option value="18">Assistenza Generica</option>
    	<option value="17">Certificazione Linea</option>
    
    </select>
    Code:
    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>
    sorry for my english, I'm using google translator

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2019
    Posts
    2

    Re: automate onchange event with javascript...

    no one can help me?

  3. #3
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    316

    Re: automate onchange event with javascript...

    Quote Originally Posted by ilsaggio View Post
    no one can help me?
    im sure lots of people can help you but you are going to have to wait for them to donate their time to your issue.

    If you need a faster response, put a programmer or two on retainer and negotiate an hourly rate.

  4. #4
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: automate onchange event with javascript...

    Welcome to the Forums.

    First I dont see a valid url link?

    Without knowing the webpage its hard to see if they have anything preventing you from automating it. This may also be against their terms of use.

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Hyperactive Member
    Join Date
    Mar 2018
    Posts
    316

    Re: automate onchange event with javascript...

    Quote Originally Posted by RobDog888 View Post
    [color=navy]Welcome to the Forums.

    First I dont see a valid url link?
    its a page on an internal server

    All the elements are exposed and you can interact with their methods. For example, to click a button, you can do:

    webBrowser1.Document.All("YourButtonName").InvokeMember("click")

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,420

    Re: automate onchange event with javascript...

    Code:
    System.Windows.Forms.Application.DoEvents()
    From that alone we can already see that you have posted in the wrong forum.

  7. #7
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,688

    Re: automate onchange event with javascript...

    This isnt a vb issue per se and probably should break it down to smaller sections. Since you are on the javascript portion perhaps you would get better responses focusing on that part.

    I can move the thread upon your reply.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width