0
Good night! I have a listview and I am displaying the values inside Span’s, I would like to take the value of span when clicking but as Span’s have the same ID I always get the same value.
Does anyone have any idea 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>
because you didn’t use the controller to do that?
– novic
Because I need to list all the values, then I get the data by clicking and plotting on a map. Hence the need to list all the data.
– Pedro Vanderlan Santana
I said the following! why didn’t you use the component?
– novic
Excuse my ignorance, but can you send a supporting documentation or an example? I really am Noob
– Pedro Vanderlan Santana
<span class='fc-event' ID="ooooo" onclick="controle()"><%# Eval("Expr1") %></span>
the problem is here ?– novic
Exact. It displays more than 200 results but when clicking on one of them I always get the value of the first one using the control function()
– Pedro Vanderlan Santana
I can see your javascript control() ?
– novic
<script> Function control(e) { var others = Document.getElementById('ooooo'). textContent; Alert(others); } </script>
– Pedro Vanderlan Santana