Reverse the words
|
|
<HTML> <HEAD> <SCRIPT> function revWords(str){ words = str.split(" "); j = words.length - 1; backWords = new Array(); for (i=0 ; i < words.length ; i++){ backWords[j] = words[i]; j-- } document.theForm.results.value = backWords.join(" "); } </SCRIPT> </HEAD> <BODY> <FORM name="theForm"> Enter a text string: <TEXTAREA name=inStr rows=5 cols=90> </TEXTAREA> <INPUT type=button value="Reverse Words" onClick="revWords(document.theForm.inStr.value)";> <INPUT type=button name="theButton" value="Clear Results" onClick='document.theForm.results.value=""';> Results<br> <TEXTAREA name=results rows=5 cols=90> </TEXTAREA>
</FORM> </BODY> </HTML>
|
|
|
HTML code for linking to this page:
Related in same category :
-
-
|