How to add javascript functions to events using ASP:ComboBox
<p>Please have mercy, working in ASP is not my native environment. I have a <a href="http://dotnetslackers.com/articles/aspnet/Custom_ASPNET_ComboxBox_Control.aspx#1316" rel="nofollow">ComboBox</a> that is populated with ListItems during the load of the page. I need to get information out of the selected items value when the user selects one of the entries, but every hook for an event I have tried has done nothing. </p>

<p>What can I do to cause a selected index change to fire my Javascript?</p>

<p>The control: <code>&lt;asp:ComboBox ID="cboFighterGym" name="cboFighterGym" runat="server" AutoPostBack="False"
                                            DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" CaseSensitive="False"
                                            ItemInsertLocation="Append" onchange="hello();" ClientIDMode="Static" &gt;
                                        &lt;/asp:ComboBox&gt;</code></p>

<pre><code>var sel = document.getElementById("cboFighterGym");
        alert(sel.toString()); // This outputs [object HTMLDivElement]
        sel.onchange = function () {
            alert("Selected value: " + this.value); // This never happens
        };
</code></pre>

<p>When I run it the section appears to look like this: </p>

<pre><code>&lt;div id="cboFighterGym" name="cboFighterGym" onchange="hello();" onFocus="alert(&amp;#39;Hello&amp;#39;)" style="display:inline-block;"&gt;
&lt;table id="Table" class="ajax__combobox_inputcontainer" cellspacing="0" cellpadding="0" style="border-width:0px;border-style:None;border-collapse:collapse;display:inline-block;position:relative;top:5px;"&gt;
    &lt;tr&gt;
        &lt;td class="ajax__combobox_textboxcontainer"&gt;&lt;input name="cboFighterGym$TextBox" type="text" id="TextBox" autocomplete="off" /&gt;&lt;/td&gt;&lt;td class="ajax__combobox_buttoncontainer"&gt;&lt;button id="Button" type="button" style="visibility:hidden;"&gt;&lt;/button&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;&lt;ul id="OptionList" class="ajax__combobox_itemlist" style="display:none;visibility:hidden;"&gt;
    &lt;li&gt;Select a Gym&lt;/li&gt;&lt;li&gt;Other&lt;/li&gt;&lt;li&gt;555 555, Oregon&lt;/li&gt;

&lt;/ul&gt;&lt;input type="hidden" name="cboFighterGym$HiddenField" id="HiddenField" value="0" /&gt;
</code></pre>

<p></p>
