title: Get Dropdown Box to Appear from TextBox
body: <p>The following excel vba macro will open a webpage and insert "500010" into a text box.  If you manually type the same number into the textbox, a dropdown box will appear with further selections.  This doesn't occur with the programmatic number entry.  I've tried a number of ways to programmatically get this dropdown box to appear, a few are shown in my code, but to no avail. </p>
  
  <pre><code>Sub test()
  
  URL = "http://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?expandable=7&amp;flag=0"
  
  Set ie = CreateObject("InternetExplorer.Application")
      ie.Visible = True
      ie.navigate URL
  
  Do Until (ie.readyState = 4 And Not ie.Busy)
      DoEvents
  Loop
  
  ie.Document.getElementById("ctl00_ContentPlaceHolder1_GetQuote1_txtscrip_code").Value = 500010 
  
  ' click the textbox to get the dropdown box to appear
  ie.Document.getElementById("ctl00_ContentPlaceHolder1_GetQuote1_txtscrip_code").fireevent ("onClick")
  ie.Document.getElementById("ctl00_ContentPlaceHolder1_GetQuote1_txtscrip_code").Click
  end sub
  </code></pre>
  
  <p>If I look at the source code for the webpage, I see the following prior to information about the textbox.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    function cleartext1(a) {
            if (a.value == "Scrip code/Scrip Name")
                a.value = '';
  
        }
        function Filltext1() {
            a.value == "Scrip code/Scrip Name"
  
        }
       function ClearTextBox(a)
      {    
          if (a.value == a.defaultValue) a.value = "";
      }
      function FillTextBox(a) 
      {
          if (a.value == "") a.value = a.defaultValue;
      }
      function HiddenValue(hdn) { 
  
          var hvalue = document.getElementById(hdn).value;
          if (hvalue != "") 
          {  
              var s1=hvalue.split("|");
              location.href = "/StockReach/AdvanceStockReach.aspx?scripcode=" + s1[0];
              return true;
          }
         else
              return false;
      }
  
  //    function chk(e)
  //    {
  //    if(window.event)
  //    {
  //        var key=window.event.keyCode;
  //        if (key == 13) 
  //        {
  //            var btn = document.getElementById('btnGetQuote');
  //            //  HiddenValue('hdnIdAsset');
  //            
  //          btn.click();
  //          //btn.focus();
  //        }
  //      }
  //    }
  &lt;/script&gt;
  &lt;div id="ctl00_ContentPlaceHolder1_GetQuote1_Pn1" onkeypress="return noenter(event);"&gt;
  
  &lt;table border="0" cellspacing="0" cellpadding="2" align="left"&gt;
      &lt;tr&gt;
          &lt;td style ="padding-right:10px;"&gt;
              &lt;input value="" id="divshow" type="hidden" /&gt;
              &lt;input value="" id="hdnIdAsset" type="hidden" /&gt;&lt;input name="ctl00$ContentPlaceHolder1$GetQuote1$hdnValue" type="hidden" id="ctl00_ContentPlaceHolder1_GetQuote1_hdnValue" /&gt;
  
              &lt;input name="ctl00$ContentPlaceHolder1$GetQuote1$txtscrip_code" type="text" maxlength="500" id="ctl00_ContentPlaceHolder1_GetQuote1_txtscrip_code" value="Scrip code/Scrip Name" class="textbox2" onclick="javascript:selecttxt(this);" onkeypress="javascript:noenter(event);return chkkey(event,this);" onfocus="cleartext1(this);" onblur="FillTextBox(this)" onkeyup="javascript:showDivSelect(event,'Asset','http://www.bseindia.com/common/backpageAsset.aspx',this,this.value,3,'0',false);" style="width:160px;" /&gt;
  </code></pre>
  
  <p>I'm not very familiar with writing javascript functions for vba, but I tried putting the following in my macro, but it created an error.</p>
  
  <p>f = "function (hiddenvalue)  '<a href="http://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?/StockReach/AdvanceStockReach.aspx?scripcode=500010" rel="nofollow">http://www.bseindia.com/markets/equity/EQReports/StockPrcHistori.aspx?/StockReach/AdvanceStockReach.aspx?scripcode=500010</a>').value = 'True';}"
      ie.Document.parentWindow.execScript f, "jscript"
      ie.Document.getElementById("ctl00_ContentPlaceHolder1_GetQuote1_txtscrip_code").Click</p>
  
  <p>Am I on the right track, is a javascript function in my code what's needed here?  Can someone help me come up with the code to get the dropdown box to appear?..TIA, Ron</p>