Replace the Space With a (+)

Today, we look at the code that searches the keywords entered in this script.

provided by: 
Originally published at Internet.com


Tip Forty-Tree...

I have found that one of the hardest things about writing a JavaScript is trying to set up code so that every possible thing a user could do is handled in one way or another. I always forget something.

The author of this script put in some code that I would never have thought of. Many of you know that when using a search engine, a plus sign (+) between words is a good idea to help to search. Today, we look at the code that searches the keywords entered in this script. If a space is found, then a plus sign replaces it.

But first, refresh yourself on the effect and code of this Script.

-----------------------------------

Enter the Keyword :

Select the Search Engine(s):
Yahoo
Altavista
WebCrawler
Excite
Lycos

-----------------------------------

Here's the Code

-----------------------------------

I am worried about the code that makes up the first function, wordsplit(items). It looks like this:

function wordsplit(items) { var charect = ""; for (var n = 1 ; n <= items.length ; n++) { if (items.substring(n-1,n) == " ") { charect+="+"; } else { charect+=items.substring(n-1,n); } } return charect; } ...

Read article at Internet.com site
Related Articles
- The Case for Components
In Paul Kimmel's latest column from CodeGuru.com, he tackles the hype about classes and components. In doing so, he even presents you with information on the splitter control within Visual Basic .NET.
- Diary of a Web Developer: Fork in the Road
- Understanding New JScript .NET Statements
- So, You Want A Menu, Huh?
- Auto repositioning/resizing of child controls (using C++ templates)
- Box Properties
- Branching Method
Regional Articles
- Replace the Space With a (+) Alabama
- Replace the Space With a (+) Alaska
- Replace the Space With a (+) Arizona
- Replace the Space With a (+) Arkansas
- Replace the Space With a (+) California
- Replace the Space With a (+) Colorado
- Replace the Space With a (+) Connecticut
- Replace the Space With a (+) DC
- Replace the Space With a (+) Delaware
- Replace the Space With a (+) Florida
- Replace the Space With a (+) Georgia
- Replace the Space With a (+) Hawaii
- Replace the Space With a (+) Idaho
- Replace the Space With a (+) Illinois
- Replace the Space With a (+) Indiana
- Replace the Space With a (+) Iowa
- Replace the Space With a (+) Kansas
- Replace the Space With a (+) Kentucky
- Replace the Space With a (+) Louisiana
- Replace the Space With a (+) Maine
- Replace the Space With a (+) Maryland
- Replace the Space With a (+) Massachusetts
- Replace the Space With a (+) Michigan
- Replace the Space With a (+) Minnesota
- Replace the Space With a (+) Mississippi
- Replace the Space With a (+) Missouri
- Replace the Space With a (+) Montana
- Replace the Space With a (+) Nebraska
- Replace the Space With a (+) Nevada
- Replace the Space With a (+) New Hampshire
- Replace the Space With a (+) New Jersey
- Replace the Space With a (+) New Mexico
- Replace the Space With a (+) New York
- Replace the Space With a (+) North Carolina
- Replace the Space With a (+) North Dakota
- Replace the Space With a (+) Ohio
- Replace the Space With a (+) Oklahoma
- Replace the Space With a (+) Oregon
- Replace the Space With a (+) Pennsylvania
- Replace the Space With a (+) Rhode Island
- Replace the Space With a (+) South Carolina
- Replace the Space With a (+) South Dakota
- Replace the Space With a (+) Tennessee
- Replace the Space With a (+) Texas
- Replace the Space With a (+) Utah
- Replace the Space With a (+) Vermont
- Replace the Space With a (+) Virginia
- Replace the Space With a (+) Washington
- Replace the Space With a (+) West Virginia
- Replace the Space With a (+) Wisconsin
- Replace the Space With a (+) Wyoming
Related Articles
- The Case for Components
In Paul Kimmel's latest column from CodeGuru.com, he tackles the hype about classes and components. In doing so, he even presents you with information on the splitter control within Visual Basic .NET.
- Diary of a Web Developer: Fork in the Road
- Understanding New JScript .NET Statements
- So, You Want A Menu, Huh?
- Auto repositioning/resizing of child controls (using C++ templates)
- Box Properties
- Branching Method

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML