0

How to get an text field text in to an array? Is it possible to get a text from text field and put it in to character array to select each Alphabet and use it in different places?

Like I have a words

Computer
<input type="text" name="name" />

I need it like in different Block Like Name Speel

[C] [o] [m] [p] [u] [t] [e] [r]

Any help appreciated.

Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116
  • possible duplicate of [JavaScript string to array conversion](http://stackoverflow.com/questions/13272406/javascript-string-to-array-conversion) – APerson Jul 20 '14 at 17:28
  • @APerson It isn't a duplicate, since it is splitting a string using a comma instead of an empty character. – Anderson Green Jul 20 '14 at 17:36
  • 1
    @AndersonGreen Well, many of the answers there are about how to split on a random character, which is more or less the point of this question. – APerson Jul 20 '14 at 17:40
  • Who says it is duplicate i am asking for word "computer" in split them in to [c] [o] [m] [p] [u] [t] [e] [r] the main thing is break in to alphabets and in the form of blocks –  Jul 20 '14 at 17:56
  • i want to know that whether this type of function is available in JavaScript or not –  Jul 20 '14 at 17:58

2 Answers2

2

What you might want is the following JavaScript:

"Computer".split("")
slaweet
  • 385
  • 2
  • 17
0

I think that the main problem is this part: "select each Alphabet and use it in Different Places Like..." so the solution is to use .charAt() function.

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var str = "How are you doing today?";
    var res = str.charAt(0);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>
alexqc
  • 547
  • 4
  • 9
  • Thanks This what i wanted. I searched about it but i did not found thanks once again my friend told me about this web site for Question not be found –  Jul 20 '14 at 17:47