473,659 Members | 2,662 Online
Bytes | Software Development & Data Engineering Community
+ 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="T rue"></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 1507
"Eddie Clark" <ed***@coolclar k.com> wrote in message
news:%2******** *********@TK2MS FTNGP11.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="T rue"></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.for m1.ListBox.opti ons[i].selected)
{
alert(document. form1.ListBox.o ptions[i].value + ' is selected');
}
else
{
alert(document. form1.ListBox.o ptions[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******** ******@TK2MSFTN GP09.phx.gbl...
"Eddie Clark" <ed***@coolclar k.com> wrote in message
news:%2******** *********@TK2MS FTNGP11.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="T rue"></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.for m1.ListBox.opti ons[i].selected)
{
alert(document. form1.ListBox.o ptions[i].value + ' is selected');
}
else
{
alert(document. form1.ListBox.o ptions[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***@coolclar k.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.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******** ******@TK2MSFTN GP09.phx.gbl...
"Eddie Clark" <ed***@coolclar k.com> wrote in message
news:%2******** *********@TK2MS FTNGP11.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="T rue"></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.for m1.ListBox.opti ons[i].selected)
{
alert(document. form1.ListBox.o ptions[i].value + ' is selected');
}
else
{
alert(document. form1.ListBox.o ptions[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***@coolclar k.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.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***@coolclar k.com> wrote in message
news:eQ******** ******@tk2msftn gp13.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
1588
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 scripts I maintain a set of counters, one on each of my HTML pages that they host. It is all very basic, the files are no more then textfiles that ONLY contain the number of hits, as a characterstring. The filename is free for me to choose, the...
3
1470
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? thanks in advance, ed
3
3534
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 reloading the page. The only way i can think of doing such a thing is having an active server page that returns an image, that is generated on the fly. As long as there is no caching on the client this in theory will allow the client to perform an...
1
1039
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 removes these blocks (there could be any number of blocks on a page). I am now using asp.net with server controls. How do i go about dynamically add and removing server controls on the client side, is it possible? Please could someone give me...
0
1639
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 rendering time to provide a total "user experience" time. An example of where it might be used would be on a search page that allows a user to enter some text and click a search button. I would like to track from the time the user clicked the...
10
2382
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 time to populate the array in the javascript after the datagrid is populated. What I am thinking of doing is creating a comma delimited string on the server side (.vb) and then have the javascript pick it up through array().... My problem...
1
2608
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 need to be able register using an html form, and then also be able to login. I know approximately zero javascript/php, and all I have as of now is a script that I found here earlier today, found here. ANY help would be greatly appreciated, as I've...
1
1329
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
5474
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.
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6178
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.