Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

input box with spaces into variables

Status
Not open for further replies.

JeroenP

Programmer
Mar 26, 2002
8
NL
Hello,

I have an input box
<INPUT TYPE=&quot;text&quot; NAME=&quot;name&quot; SIZE=70>

Now i want a function that puts the user input into variables. After every space a new variable.

example:
I enter the tekst: hello this is a test

The javascript function should do this:
var1 gets the value hello,
var2 gets the value this,
var3 gets the value is,
etc. etc.

Is it possible? And does anyone know how to do it?

Jeroen

 
function splitAll(formObj)
{
var splittedValues = formObj.value.split(&quot; &quot;);
for (var i = 0; i < splittedValues.length; i++)
{
eval(&quot;var&quot; + i + &quot; = &quot; + splittedValues)
}
}

formObj assumes that you have a .value attribute to the element.

hope this helps. Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top