473,473 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Really dumb question: Access server listbox from client side

I'm trying to access the items in a listbox from a client-side vb script.

<asp:listbox id="ListBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 120px" runat="server" Width="400px" Height="104px"
AutoPostBack="True"></asp:listbox>

I've tried several different ways using document.form1.listbox1 but nothing
seems to work

Any help would be appreciated.
Nov 18 '05 #1
5 1495
"Eddie Clark" <ed***@coolclark.com> wrote in message
news:%2*****************@TK2MSFTNGP11.phx.gbl...
I'm trying to access the items in a listbox from a client-side vb script.

<asp:listbox id="ListBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 120px" runat="server" Width="400px" Height="104px"
AutoPostBack="True"></asp:listbox>

I've tried several different ways using document.form1.listbox1 but
nothing seems to work

Any help would be appreciated.


<script>
for(var i = 0; i < document.form1.ListBox.length; i++)
{
if(document.form1.ListBox.options[i].selected)
{
alert(document.form1.ListBox.options[i].value + ' is selected');
}
else
{
alert(document.form1.ListBox.options[i].value + ' is not selected');
}
}
</script>

Also, note that JavaScript is case-sensitive, so there's no point in using
document.form1.listbox1 to try to refer to a dropdown whose id is actually
ListBox1...
Nov 18 '05 #2
Thanks Mark,

I am using vbscript but if I have to I'll use java, of course I'll have to
learn java :-)

Also I'm only trying to access the first item in the list box. then I will
delete it from the server side.
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
"Eddie Clark" <ed***@coolclark.com> wrote in message
news:%2*****************@TK2MSFTNGP11.phx.gbl...
I'm trying to access the items in a listbox from a client-side vb script.

<asp:listbox id="ListBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 120px" runat="server" Width="400px" Height="104px"
AutoPostBack="True"></asp:listbox>

I've tried several different ways using document.form1.listbox1 but
nothing seems to work

Any help would be appreciated.


<script>
for(var i = 0; i < document.form1.ListBox.length; i++)
{
if(document.form1.ListBox.options[i].selected)
{
alert(document.form1.ListBox.options[i].value + ' is selected');
}
else
{
alert(document.form1.ListBox.options[i].value + ' is not
selected');
}
}
</script>

Also, note that JavaScript is case-sensitive, so there's no point in using
document.form1.listbox1 to try to refer to a dropdown whose id is actually
ListBox1...

Nov 18 '05 #3
Here' something I've tried

msgbox document.form1.ListBox.options[1].value

no luck

"Eddie Clark" <ed***@coolclark.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Thanks Mark,

I am using vbscript but if I have to I'll use java, of course I'll have to
learn java :-)

Also I'm only trying to access the first item in the list box. then I
will delete it from the server side.
"Mark Rae" <ma**@mark-N-O-S-P-A-M-rae.co.uk> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
"Eddie Clark" <ed***@coolclark.com> wrote in message
news:%2*****************@TK2MSFTNGP11.phx.gbl...
I'm trying to access the items in a listbox from a client-side vb
script.

<asp:listbox id="ListBox1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 120px" runat="server" Width="400px" Height="104px"
AutoPostBack="True"></asp:listbox>

I've tried several different ways using document.form1.listbox1 but
nothing seems to work

Any help would be appreciated.


<script>
for(var i = 0; i < document.form1.ListBox.length; i++)
{
if(document.form1.ListBox.options[i].selected)
{
alert(document.form1.ListBox.options[i].value + ' is selected');
}
else
{
alert(document.form1.ListBox.options[i].value + ' is not
selected');
}
}
</script>

Also, note that JavaScript is case-sensitive, so there's no point in
using document.form1.listbox1 to try to refer to a dropdown whose id is
actually ListBox1...


Nov 18 '05 #4
"Eddie Clark" <ed***@coolclark.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I am using vbscript but if I have to I'll use java, of course I'll have to
learn java :-)
Firstly, the example I gave you has NOTHING WHATSOEVER to do with Java - it
is JavaScript - similar name, but totally different technology...
Also I'm only trying to access the first item in the list box. then I
will delete it from the server side.


Do you mean the first item that the user has selected...?
Nov 18 '05 #5
"Eddie Clark" <ed***@coolclark.com> wrote in message
news:eQ**************@tk2msftngp13.phx.gbl...
msgbox document.form1.ListBox.options[1].value

no luck


1) You said your dropdown's ID is ListBox1, not ListBox...

2) options[1] refers to the second option in the dropdown, not the first -
to refer to the first option, use options[0]
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marcel Brekelmans | last post by:
Hi, This is my situation: My ISP doesn't allow me the execute server-code. So, no ASP or otherwise.As a small compensation, they run some CGI scripts that we can use. With one of these...
3
by: ed | last post by:
I've just started working with .Net, so appologize for what is probably a really dumb question. Did Windows XP originally come with the .Net framework installed, and if so which version? ...
3
by: BluDog | last post by:
Hi I am a bit of a novice with JS and this may seem like a completely stupid question, but i want to be able to update a bit of text on a page based on information from the server without...
1
by: jkhome | last post by:
I have a page which has a block of form elements. If i was writing the page in normal asp and javascript it would be easy for me to dynamically write client side script which dynamically adds and...
0
by: brianpmccullough | last post by:
Hello, Anyone ever implemented a solution that allows you to track the total page request time in and ASP.NET page? The time would need to include the server processing time and client side...
10
by: Lyners | last post by:
Hello all, I have an ASP.NET website where one of my pages contain javascript that is a check to see if anydata within a datagrid has changed. My problem is that it takes a considerable amount of...
1
by: Sunlis | last post by:
I need to find a way to communicate with a MS Access database using Javascript, PHP, or some other client-side scripting. It's for a Computer Science exam, and I cannot solve this problem. Users...
1
idsanjeev
by: idsanjeev | last post by:
Hello What is server and client side code. where can use server side code and where client side Thanks
3
by: malathib | last post by:
Hi, In my web application, in one of the screen when the user clicks on one link, it has to open a folder that was located in server in client side.
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.