Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html xmlns = "http://www.w3.org/1999/xhtml">
- <head>
- <title>String Method split and substring</title>
- <script type = "text/javascript">
- <!--
- function splitButtonPressed()
- {
- var strings = myForm.inputVal.value.split( " " );
- myForm.output.value = strings.join( "\n" );
- myForm.outputSubstring.value =
- myForm.inputVal.value.substring( 0, 10 );
- }
- // -->
- </script>
- </head>
- <body>
- <form name = "myForm" action = "">
- <p>Enter a sentence to split into words<br />
- <input name = "inputVal" type = "text" size = "40" />
- <input name = "splitButton" type = "button" value =
- "Split" onclick = "splitButtonPressed()" /></p>
- <p>The sentence split into words is<br />
- <textarea name = "output" rows = "8" cols = "34">
- </textarea></p>
- <p>The first 10 characters of the input string are
- <input name = "outputSubstring" type = "text"
- size = "15" /></p>
- </form>
- </body>
- </html>
Advertisement
RAW Paste Data
Copied
Advertisement