If I have an array set up like so to contain a small code, and the name of
the person to whom the code relates, the values split by a comma:
DMCName[0]="1SC,Andrea Pidgeon"
and I want to be able to return the name when someone enters the code into a
text box, is there a way to split the array and only return the name? -
Bearing in mind that there will be more than one code, and other details
will be included besides the name of the person, and that such a method of
splitting would have to be able to scan through all (roughly 40 entries) in
the array and compare the code to the users entry... 1 1870
Andi B wrote: If I have an array set up like so to contain a small code, and the name of the person to whom the code relates, the values split by a comma:
DMCName[0]="1SC,Andrea Pidgeon"
and I want to be able to return the name when someone enters the code into a text box, is there a way to split the array and only return the name? - Bearing in mind that there will be more than one code, and other details will be included besides the name of the person, and that such a method of splitting would have to be able to scan through all (roughly 40 entries) in the array and compare the code to the users entry...
The split() method returns an array:
var splitStuff = DMCName[0].split(/,/);
var userInput = "whatever";
for (var i = 0; i < splitStuff.leng th; i++) {
if (splitStuff[i] == userInput) {
// you found a match
break;
}
}
If you know the name is always the second thing in the string, you could also do
something like:
if (DMCName[0].split(/,/)[1] == userInput) {
// found a match
}
--
| Grant Wagner <gw*****@agrico reunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
* http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rakesh |
last post by:
Hi,
I was 'googling' to look out for some ways of optimizing the code
and came across this term - 'hot / cold splitting'.
In short, the discussion is about splitting heavily accessed ( hot )
portions of data structure from rarely accessed cold portions.
I haven't used this one myself anytime before, but am interested in
learning more about this.
Can you please share your experience here, so that I can understand
better and this could...
|
by: Steve Darby |
last post by:
Can anyone help with this problem. I am attempting to dynamically draw a
graph using data from a cookie. I have written the script to actually draw
the graph, for which I hav created two arrays with the data I required
preset into them. What I wish to do is split the cookie in which the data
is stored and create two array from it.
The function used to create the cookie is as follows
:function SetCookie(name, value) {...
|
by: James Conrad St.John Foreman |
last post by:
One of the larger tables in our database is now 6.8 million rows (1 per
financial transaction since 2000).
Every time an amendment is made to a booking, new rows are added to the
table for each transaction, so in general we never have any call to
update old rows. Usually, we only deal with analysis on transactions
in the current financial year or the previous one, but *occasionally*
we'll want to go back further.
So I'm thinking as...
|
by: r035198x |
last post by:
Breaking up a string
Instead of using the old StringTokenizer class, a simple trick is to use the String.split method.
String string = "This is a string";
String tokens = string.split(" ");
for(String s: tokens) {
System.out.println(s);
}
|
by: shadow_ |
last post by:
Hi i m new at C and trying to write a parser and a string class.
Basicly program will read data from file and splits it into lines then
lines to words. i used strtok function for splitting data to lines it
worked quite well but srttok isnot working for multiple blank or
commas. Can strtok do this kind of splitting if it cant what should i
use .
Unal
| |
by: techusky |
last post by:
I am making a website for a newspaper, and I am having difficulty
figuring out how to take a string (the body of an article) and break
it up into three new strings so that I can display them in the
traditional newspaper column format.
For instance, say the string $articleBody contains a 600 word article.
What I want to do is break $articleBody up into three new strings in a
format such as this:
$string1 contains words 0-200 from...
|
by: Alexander Adam |
last post by:
Hi!
I've got an input wchar_t array in a callback function from expat:
void my_callback(const wchar_t* data);
Additionally, I got a second function that I need to call within my
callback with:
void my_call_to(const wchar_t** arr);
|
by: spreadbetting |
last post by:
I'm trying to split a string into an separate arrays but the data is
only delimited by a comma. The actual data is one long string but the
info is in a regular format and repeats after every five ~'s .
i.e the data may be returned as
1.01~11844.69~0.0~0.0~2.0~1.02~117.3~0.0~0.0~0.0~1.03~66.82~0.0~0.0~0.0~1.0
4~300.0~0.0~0.0~0.0~
|
by: pereges |
last post by:
I've an array :
{100,20, -45 -345, -2 120, 64, 99, 20, 15, 0, 1, 25}
I want to split it into two different arrays such that every number <=
50 goes into left array and every number 50 goes into right array.
I've done some coding but I feel this code is very inefficient:
void split_array(int *a, int size_of_array)
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |