473,480 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array of listbox

rajiv07
141 New Member
Hi I am using an array of listboxes .here i want to get the index of the listbox when it get changed.I have spent 1 Hour for this problem but i could not sort this problem.

Please Help me on this.

Thanks
Rajiv
Mar 19 '08 #1
5 1672
gits
5,390 Recognized Expert Moderator Expert
hi ...

please post the code you have so far ...

kind regards
Mar 19 '08 #2
rajiv07
141 New Member
hi ...

please post the code you have so far ...

kind regards
Thanks gits

Expand|Select|Wrap|Line Numbers
  1. var position;
  2. for(i=0;i<=document.form1.ref_type.length;i++){
  3. if(document.form1.ref_type[i].change==true){
  4. position=i; }
  5.  }
  6.  
But this is not working.

Thanks

Rajiv
Mar 19 '08 #3
gits
5,390 Recognized Expert Moderator Expert
that will not work that way. how do you construct the array of your listboxes and whatfor do you need the index to be retrieved? lets sort out this together ... the idea would be:

1. don't use an array but an object
2. onchange of the select-node we retrieve its position in the list

kind regards
Mar 19 '08 #4
rajiv07
141 New Member
that will not work that way. how do you construct the array of your listboxes and whatfor do you need the index to be retrieved? lets sort out this together ... the idea would be:

1. don't use an array but an object
2. onchange of the select-node we retrieve its position in the list

kind regards
Please could you post any sample code or sites to refer form this.

Thanks
Mar 19 '08 #5
gits
5,390 Recognized Expert Moderator Expert
ok assuming we use the following code:

Expand|Select|Wrap|Line Numbers
  1. var list   = document.getElementsByTagName('select');
  2. var lookup = {};
  3.  
  4. for (var i = 0, n; n = list[i]; i++) {
  5.     lookup[n.name] = i;
  6. }
  7.  
lookup now looks like this pseudocode:

Expand|Select|Wrap|Line Numbers
  1. { select_name: select_index_in_list }
now you could use a function like this in the onchange of the select-node:

Expand|Select|Wrap|Line Numbers
  1. function get_idx(node) {
  2.     return lookup[node.name];
  3. }
[HTML]<select name="my_name" onchange="get_idx(this);">[/HTML]
where the function returns you the index in list

kind regards
Mar 19 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7540
by: Deano | last post by:
I needed to have a listbox populated by locations which are stored in tblLocations. However I wanted an "All locations" entry to be at the top of the listbox. This is not in the tblLocations. The...
3
8875
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
11
8528
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
1
2752
by: A. Spiehler | last post by:
I'm trying to fill a listBox control with string members from an array of objects. I think using data binding is supposed to be the easiest way to do this. I've never used data binding before and...
6
2325
by: Paul | last post by:
Hi All, Framework 1.1 listbox control unable to DataBind I've been googling for an answer to this query that appears quite a lot, but none, it seem, answers my problem directly. I am...
1
1489
by: pauled | last post by:
Hello all, Framework 1.1 VS 2003 Binding listbox. I have an array of objects that I am trying to use as the datasource for a listbox. The array is returned from a webservice and seems to be...
0
5559
by: raypjr | last post by:
Hi everyone. I'm new here and hope I can get a little advice on how to list my array into a ListBox. I have my structure and array of structures. I need help with a For Loop that will list the...
2
1992
by: raypjr | last post by:
Hi everyone. I'm new here and hope I can get a little advice on how to list my array into a ListBox. I have my structure and array of structures. I need help with a For Loop that will list the...
2
6292
by: php_Boi | last post by:
i have designed an application that is a dynamic submission form. i have text fields and listboxes. now i am able to retain the values of the listboxes when i populate the listbox "manually"(single...
3
3458
by: Sweetiecakes | last post by:
Hi I have an string array containing file paths. I have added them to a ListBox with AddRange(); When I delete an item from the ListBox, how can I delete the same item from the original...
0
6908
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
7087
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
6741
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
6944
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...
1
4782
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
4483
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...
0
2995
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...
0
1300
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 ...
0
182
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...

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.