check this
http://stackoverflow.com/questions/3297174/jquery-any-item-selected-in-listbox[
^]
http://stackoverflow.com/questions/3113851/selecting-item-from-asp-net-listbox-using-jquery[
^]
Here is the code
<div>
<asp:ListBox ID="ListBox1" runat="server" Width="50px" Height="100px"
SelectionMode="Multiple">
<asp:ListItem Value="One">1</asp:ListItem>
<asp:ListItem Value="Two">2</asp:ListItem>
<asp:ListItem Value="Third">3</asp:ListItem>
<asp:ListItem Value="Four">4</asp:ListItem>
<asp:ListItem Value="Five">5</asp:ListItem>
</asp:ListBox>
<br />
<asp:TextBox ID="text1" runat="server"></asp:TextBox>
</div>
<script type="text/javascript">
$("#<%=ListBox1.ClientID %>").change(function () {
$("#<%=text1.ClientID %>").val($(this).val());
});
</script>
Hope it helps...
Edited
Jquery code
$("#<%=ListBox1.ClientID %>").change(function () {
var selectedItems = $(this).val();
var value = 0;
for (var i = 0; i < selectedItems.length; i++) {
value = parseInt(value)+ parseInt(selectedItems[i]);
}
$("#<%=text1.ClientID %>").val(value);
});
Assuming the listbox is like this
<asp:ListBox ID="ListBox1" runat="server" Width="50px" Height="100px"
SelectionMode="Multiple">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
<asp:ListItem Value="3">3</asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
<asp:ListItem Value="5">5</asp:ListItem>
</asp:ListBox>