473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

If given 1 element in an array of textboxes... find which element number it is


I call this Javascript function with "GetEleNum(this)"
passing it 1 of the elements of a text-box array.

Is there a QUICK way to get the "element #"? I'm currently using this
SLOW code.
(It works... but I need something better/faster.)

function GetEleNum(c)
{
// Given 1 element in this textBox array... what is the array element #?

var i;

for(i=0; i<form1.txtBox.length; i++)
if(form1.txtBox[i] == c) return i;

return 0; // Not found
}

Thanks

Nov 15 '07 #1
1 1533
On Nov 15, 8:59 pm, "\"A_Michigan_User\""
<Michigan_RE_M...@ameritech.netwrote:
I call this Javascript function with "GetEleNum(this)"
passing it 1 of the elements of a text-box array.

Is there a QUICK way to get the "element #"? I'm currently using this
SLOW code.
(It works... but I need something better/faster.)

function GetEleNum(c)
{
// Given 1 element in this textBox array... what is the array element #?

var i;

for(i=0; i<form1.txtBox.length; i++)
if(form1.txtBox[i] == c) return i;

return 0; // Not found

}

Thanks
Try organizing your question into something understandable, PLEASE!
This way, I don't know what you're asking, what you're trying to
accomplish, anything.

Suggestion nr. 1: don't use 'u' instead of 'you', '1' instead of
'one', '#' instead of 'number' etc.
Suggestion nr. 2: explain what specific terms mean, e.g. what your
txtBox's -are-, what 'element #' means
(I suppose it's an ordinal number in an array, but -
what- array, or have you maybe meant
element's ID, etc.
Suggestion nr. 3: the way you're doing it right now - DOESN'T work.
What if the element is on the first place
(index 0)? You'll understand it the same like it
wasn't found, right?

Regards
Nov 15 '07 #2

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

Similar topics

6
by: Bhavin | last post by:
Anybody quickly replies it, would be a great help! I try to create dynamic array of textboxes control in ASP.NET(C#). I got the following error while I tried to assign value to ID property of...
3
by: samneefs | last post by:
I'm wondering if there's a way to create an array of textboxes, or loop through textboxes. The textboxes are in an ASP.NET page, but the looping happens through Visual Basic. On page load,...
9
by: NewInTheGame | last post by:
I'm a beginner in VB.Net. I'm actually taking a class & so far I understand everything, but I suck when it comes to arrays. I'm sure that this is simple (I'm ashamed of asking :oops: )... I...
1
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
4
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
1
by: yawnmoth | last post by:
Given an element ID, is there a way to figure out what index one would need to use in the parentNode's childNodes array to get at that element? For example... <body> <div id="parent"> <div...
12
by: Sabiyur | last post by:
Hi All, Is there any way to find out how much memory is allocated for a given pointer. For example: int *p=new int; I know, compiler keeps the information of how much bytes are allocated...
3
by: Jacob.Bruxer | last post by:
Hi, I want to be able to append text using a For loop to each textbox in an array of textboxes that I've created, called tBoxes(). Basically I want to add a number of spaces to each textbox in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.