Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

javascript converting user input to Title Case Capitalization

Avatar of dvcrdu
dvcrduFlag for United States of America asked on
JavaScript
12 Comments1 Solution1829 ViewsLast Modified:
Experts,

I need to convert user input entered into txtInput to Initial Caps For Each Word and display it in txtOutput in the following way:

1. use the split() method to split the words in the string into a words array

2. create a for loop that uses a 2nd split() method to split the elements of the words array into a 2nd array called characters array using the toUpperCase() method to convert the 1st element in the 2nd array to uppercase

3. use the join method() to rebuild the array of words in the text string

4. use a 2nd join() method to convert the array of words back into a single text string

5. btnConvert calls the javascript code that converts the user input

I am totally clueless and brain dead on how to do this.

Any help would be greatly appreciated.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title Case</title>


</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="529" height="233" border="15" cellpadding="5" cellspacing="5">
    <tr>
      <td width="477"><label for="txtInput">Enter Text To Convert To Initial Caps</label>:
        &nbsp; 
        &nbsp; &nbsp; <input type="text" name="txtInput" id="txtInput" tabindex="1" /></td>
    </tr>
    <tr>
      <td><label for="txtOutput">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Converted To Title Case:</label>        &nbsp; &nbsp; &nbsp; <input type="text" name="txtOutput" id="txtOutput" tabindex="2" /></td>
    </tr>
    <tr>
      <td>&nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  <input type="submit" name="btnConvert" id="btnConvert" value="Convert" tabindex="3" />
      &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <label for="btnClear"></label>
      <input type="reset" name="btnClear" id="btnClear" value="Clear" tabindex="4" /></td>
    </tr>
  </table>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971Flag of Guadeloupe imageMultitechnician
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answers