Paste ListView values - GetElementByID

0

Good evening! I have a ListView and I am displaying the values inside Span's, I would like to get the value of the span when clicking but as the Span's have the same ID I always get the same value.

Does anyone have any ideas how to get around this?

<script>

      function controle(e) {

          var outros = document.getElementById('ooooo').textContent;

          alert(outros);






      }

  </script>

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">


<EmptyDataTemplate>
    <table style="" runat="server">
        <tr>
            <td>Nenhum dado foi retornado.</td>
        </tr>
    </table>
</EmptyDataTemplate>



<ItemTemplate>



      <span class='fc-event' ID="ooooo" onclick="controle()"><%# Eval("Expr1") %></span>  

</ItemTemplate>



<LayoutTemplate>
    <table runat="server">
        <tr runat="server">
            <td runat="server">
                <table runat="server" id="itemPlaceholderContainer" style="" border="0">

                    <tr runat="server" id="itemPlaceholder"></tr>
                </table>
            </td>
        </tr>
        <tr runat="server">
            <td runat="server" style="">
                <asp:DataPager runat="server" ID="DataPager1" PageSize="25">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False"></asp:NextPreviousPagerField>
                        <asp:NumericPagerField></asp:NumericPagerField>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False"></asp:NextPreviousPagerField>

                    </Fields>
                </asp:DataPager>
            </td>
        </tr>
    </table>
</LayoutTemplate>
<SelectedItemTemplate>
    <tr style="">
        <td>

    </tr>
</SelectedItemTemplate>

        </div>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:COEX_RPBConnectionString %>' SelectCommand="SELECT PROJETO + ' - ' + TITULO AS Expr1 FROM tbl_obras_projetos_final WHERE (STATUS_USUARIO = 'Execução')"></asp:SqlDataSource>
    
asked by anonymous 01.04.2018 / 00:10

1 answer

0

Set this up?

function controle(obj) 
{
	var outros = obj.textContent;
	alert(outros);
}
<label onclick="controle(this);">Número 1</label><br /><br />
<label onclick="controle(this);">Número 2</label><br /><br />
<label onclick="controle(this);">Número 3</label><br />

and in that label :

<span class='fc-event' ID="ooooo" onclick="controle(this)">
    <%# Eval("Expr1") %>
</span>

or

function controle(value) {
  alert(value);
}
<label onclick="controle('Número 1')"> Número 1</label>
<br /><br />
<label onclick="controle('Número 2')"> Número 2</label>
<br /><br />
<label onclick="controle('Número 3')"> Número 3</label><br />
<span class='fc-event' ID="ooooo" onclick="controle('<%# Eval("Expr1") %>')">
    <%# Eval("Expr1") %>
</span>
    
01.04.2018 / 01:34