<html xmlns = "http://www.w3.org/1999/xhtml"> | |
<head> | |
<title>String Methods split and substring</title> | |
<script type = "text/javascript"> | |
<!-- | |
function splitButtonPressed() | |
{ | |
var inputString = document.getElementById( "inputVal" ).value; | |
var inputString = inputString.toUpperCase(); | |
var tokens = inputString.split( " " ); | |
document.getElementById( "output" ).value = | |
tokens.join( "\n" );; | |
document.getElementById( "outputSubstring" ).value = | |
inputString.substring( 0, 10 ); | |
} // end function splitButtonPressed | |
// --> | |
</script> | |
</head> | |
<body> | |
<form action = ""> | |
<p>Enter a sentence to split into words<br /> | |
<input id = "inputVal" type = "text" size = "40" /> | |
<input type = "button" value = "Split" | |
onclick = "splitButtonPressed()" /></p> | |
<p>The sentence split into words is<br /> | |
<textarea id = "output" rows = "8" cols = "34"> | |
</textarea></p> | |
<p>The first 10 characters of the input string are | |
<input id = "outputSubstring" type = "text" | |
size = "15" /></p> | |
</form> | |
</body> | |
</html> | |
Monday, 22 February 2016
kod html untuk tukar perkataan dri besar kpd kecik dan ambil karakter terawal
kod untuk tukar perkataan dri besar kpd kecik dan ambil karakter terawal
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment