Advertisement
RokiAdhytama

Split And Substrings - Chapter 12-1

Jul 4th, 2022
896
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html xmlns = "http://www.w3.org/1999/xhtml">
  2.    <head>
  3.       <title>String Method split and substring</title>
  4.  
  5.       <script type = "text/javascript">
  6.          <!--
  7.          function splitButtonPressed()
  8.          {  
  9.             var strings = myForm.inputVal.value.split( " " );  
  10.             myForm.output.value = strings.join( "\n" );
  11.            
  12.             myForm.outputSubstring.value =
  13.                myForm.inputVal.value.substring( 0, 10 );
  14.          }
  15.          // -->
  16.       </script>
  17.    </head>
  18.  
  19.    <body>
  20.       <form name = "myForm" action = "">
  21.          <p>Enter a sentence to split into words<br />
  22.          <input name = "inputVal" type = "text" size = "40" />
  23.          <input name = "splitButton" type = "button" value =
  24.                "Split" onclick = "splitButtonPressed()" /></p>
  25.          
  26.          <p>The sentence split into words is<br />
  27.          <textarea name = "output" rows = "8" cols = "34">
  28.          </textarea></p>  
  29.    
  30.          <p>The first 10 characters of the input string are
  31.          <input name = "outputSubstring" type = "text"
  32.                size = "15" /></p>
  33.       </form>
  34.    </body>
  35. </html>
Advertisement
RAW Paste Data Copied
Advertisement