5
Answers

split string

albert albert

albert albert

11y
1.1k
1
Hi everybody,

I have this:

[code]
function splitButtonPressed()
           {
            var inputString = document.getElementById("inputVal").value;
            var tokens = inputString.split(" " + "\n");
                document.getElementById("output").value = inputString.replace(/\s+/g, ' ', "\n");
                document.getElementById("ouput").value = tokens.indexOf(inputString);
            }
            document.getElementById("outputSubstring").value = inputString.substring(0, 10);

         // end function splitButtonPressed
            // -->
           </script>
[/code]

But now for example I type: 33      88, then output ---> 33 88. But it has to be:
33
88

So the extra space is will be omitted, but it is still one the same row and not under each other How to manage that?

Thank You.
Answers (5)