locked
split doesn't work RRS feed

  • Question

  • I am doing a javascript code it uses the split method to split the words in a sentence entered by  a user...

    This is how I wrote my code so far:

    html>
    <head>
    </head>
    <body>
    Enter text:<input type="text" id="txtSentence"name="txtSentence"/></br/>
    <input type="submit" value="Display" onclick="Split()"/>
    <script>
    function Split()
    {
        var sentence=document.getElementById("txtSentence").value;
        var spltSentence=sentence.Split(" ");
     
     alert(spltSentence);
    }

    </script>
    </body>
    </html>

    Thanks in advance

    Thursday, May 30, 2013 9:50 AM

All replies

  • The method is split() lowercase. So if you use this line it should work.

    var spltSentence=sentence.split(" ")

    Thursday, May 30, 2013 10:19 AM
  • thanks it's working now

    Thursday, May 30, 2013 10:42 AM