Return dynamic CheckBoxList span ID on button click
<p>I have a dynamic <code>CheckBoxList</code> that creates an HTML table. I've listed one row to keep it simple.</p>

<pre><code>&lt;table id="checkBoxList1" border="0"&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;span someValue="neededValue"&gt;&lt;input id="checkBoxList1_0" type="checkbox" name="checkBoxList1$0" checked="checked" /&gt;&lt;label for="checkBoxList1_0"&gt;TestTopic1&lt;/label&gt;&lt;/span&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;
</code></pre>

<p>I also have an ASP button that will run javascript when clicked. I need the function to return the <code>"neededValue"</code>. Here is the ASP button and the javascript function:</p>

<pre><code>&lt;asp:Button ID="btnSubscribe" runat="server" Text="Update Subscriptions" OnClientClick="return GetSelectedItem()"/&gt;


&lt;script type="text/javascript"&gt;
function GetSelectedItem() {
    var CHK = document.getElementById("&lt;%=checkBoxList1.ClientID%&gt;");
    var checkbox = CHK.getElementsByTagName("input");
    var spans = CHK.getElementsByTagName("span");
    for (var i = 0; i &lt; checkbox.length; i++) {
        if (checkbox[i].checked) {
            alert("Selected = " + spans[i]);
        }
    }
    return false;
}
&lt;/script&gt;
</code></pre>

<p>Right now it returns a null value.</p>
