Hi there,

I got a simple list box on an ASP page. I tried to select multiple items
and use the item values to do something.

I was able to get the item values. However, I got the following error from
IE's Error on page. I have attached my VBScript below. Any idea why?

<SCRIPT language ="vbscript">
sub Launch_OnClick
dim i
For i = 0 To document.Myform.Mylist.size
msgbox document.Myform.MyList.item(i).value
Next
End Sub

ERROR
Line: 98
Char: 8
Error: Object required: 'document.Myform.Mylist.item(...)'
Code: 0
URL: .....

RE: How to select multiple items from a list box on an ASP page by v-kevy

v-kevy
Thu Dec 30 03:18:32 CST 2004

Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you're having trouble to go through all
the items in the ListBox. If there is any misunderstanding, please feel
free to let me know.

From the code you have provided, I assume that your ListBox's name is
MyList. Here I have made some changed on the code. It works fine on my
computer. HTH.

<SCRIPT language ="vbscript">
sub Launch_OnClick
dim i
For i = 0 To me.MyList.size
msgbox me.MyList.item(i).value
Next
End Sub
</SCRIPT>

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


RE: How to select multiple items from a list box on a HTML page by awong

awong
Thu Dec 30 04:01:01 CST 2004

Hi Kevin,

I forgot to tell you that I was using HTML page NOT ASP page with VBScript.

Anyway, I got:
Error: Object doesn't support this property or method: 'Me.MyList'

when I used your code.

Abel

"Kevin Yu [MSFT]" wrote:

> Hi,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you're having trouble to go through all
> the items in the ListBox. If there is any misunderstanding, please feel
> free to let me know.
>
> From the code you have provided, I assume that your ListBox's name is
> MyList. Here I have made some changed on the code. It works fine on my
> computer. HTH.
>
> <SCRIPT language ="vbscript">
> sub Launch_OnClick
> dim i
> For i = 0 To me.MyList.size
> msgbox me.MyList.item(i).value
> Next
> End Sub
> </SCRIPT>
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>

Re: How to select multiple items from a list box on an ASP page by Michael

Michael
Thu Dec 30 13:43:44 CST 2004

Abel Chan wrote:
> Hi there,
>
> I got a simple list box on an ASP page. I tried to select multiple
> items and use the item values to do something.
>
> I was able to get the item values. However, I got the following
> error from IE's Error on page. I have attached my VBScript below.
> Any idea why?

Try this:

For i = 0 To (document.Myform.Mylist.options.length - 1)
msgbox document.Myform.MyList.options(i).value
Next

The size attribute has nothing to do with how many options are in the select
element.

options Collection (SELECT) (Internet Explorer)
http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/options.asp


>
> <SCRIPT language ="vbscript">
> sub Launch_OnClick
> dim i
> For i = 0 To document.Myform.Mylist.size
> msgbox document.Myform.MyList.item(i).value
> Next
> End Sub
>
> ERROR
> Line: 98
> Char: 8
> Error: Object required: 'document.Myform.Mylist.item(...)'
> Code: 0
> URL: .....

--
Michael Harris
Microsoft MVP Scripting



Re: How to select multiple items from a list box on an ASP page by awong

awong
Thu Dec 30 14:01:02 CST 2004

It works!!!!!!!!!!

Thanks so much Michael.

Abel

"Michael Harris (MVP)" wrote:

> Abel Chan wrote:
> > Hi there,
> >
> > I got a simple list box on an ASP page. I tried to select multiple
> > items and use the item values to do something.
> >
> > I was able to get the item values. However, I got the following
> > error from IE's Error on page. I have attached my VBScript below.
> > Any idea why?
>
> Try this:
>
> For i = 0 To (document.Myform.Mylist.options.length - 1)
> msgbox document.Myform.MyList.options(i).value
> Next
>
> The size attribute has nothing to do with how many options are in the select
> element.
>
> options Collection (SELECT) (Internet Explorer)
> http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/options.asp
>
>
> >
> > <SCRIPT language ="vbscript">
> > sub Launch_OnClick
> > dim i
> > For i = 0 To document.Myform.Mylist.size
> > msgbox document.Myform.MyList.item(i).value
> > Next
> > End Sub
> >
> > ERROR
> > Line: 98
> > Char: 8
> > Error: Object required: 'document.Myform.Mylist.item(...)'
> > Code: 0
> > URL: .....
>
> --
> Michael Harris
> Microsoft MVP Scripting
>
>
>