Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting multiple selected items from ListView

69 views
Skip to first unread message

Veeru

unread,
Nov 29, 2004, 3:17:03 AM11/29/04
to

Hi,
I'm facing a problem, in multiselect listview control I'm not able to get
all the selected items in it.
Please let me know how can I do it using VBScript.

Thanks.

McKirahan

unread,
Nov 29, 2004, 8:25:51 AM11/29/04
to
"Veeru" <Ve...@discussions.microsoft.com> wrote in message
news:C07FA1D0-F71C-4AE1...@microsoft.com...

If by "multiselect listview control" you mean a multiple select form element
then look at this (which includes JavaScript alternatives wjich don't
require IE):

<html>
<head>
<title>multiple.htm</title>
<script type="text/javascript">
function selected_JS(list) {
var what = "Selected:\n";
for (var i=0; i<list.length; i++) {
if (list.options[i].selected) {
what += list.options[i].text + " = ";
what += list.options[i].value + "\n";
}
}
alert(what);
}
function selected_JS1() {
selected_JS(document.getElementById("List"));
}
function selected_JS2() {
selected_JS(document.forms[0].List);
}
</script>
<script type="text/vbscript">
Sub selected_VBS()
Dim what
what = "Selected:" & vbCrLf
Dim i
For i = 0 To document.forms(0).list.length - 1
If document.forms(0).list.item(i).selected Then
what = what & document.forms(0).list.item(i).text & " = "
what = what & document.forms(0).list.item(i).value & vbCrLf
End If
Next
MsgBox what,vbInformation,document.title
End Sub
</script>
</head>
<body>
<form>
<b>Numbers:</b>
<br>
<select name="List" multiple size="4">
<option value="1">One
<option value="2">Two
<option value="3">Three
<option value="4">Four
</select>
<br>
<input type="button" value="selected_JS1()" onclick="return selected_JS1()">
<br>
<input type="button" value="selected_JS2()" onclick="return selected_JS2()">
<br>
<input type="button" value="selected_VBS()" onclick="return selected_VBS()">
<br>
<input type="reset" value="Clear selected">
</form>
</body>
</html>

If it's a Webcontrol you're talking about then try this newsgroup:

microsoft.public.dotnet.framework.aspnet.webcontrols


0 new messages