2017-05-03 33 views
-4

這就是我到目前爲止 - 我可以幫助獲得「alphabetized」版本顯示嗎?我一直試圖添加不同的東西,但我不知道應該留下什麼,應該怎麼做。我能得到一些關於如何解決這個問題的提示嗎?如何創建一個Alphabetizer程序?

<!DOCTYPE html> 
    <html> 
    <head> 
    <title> Alphabetizer</title> 
    </head> 

    <body> 


    <script> 
    <p id="words"></p> 
    function sumbitFunction(); { 
    var words = document.getElementById("words"); 
    var input= input.sort(); 
    words.textContent = input.join(); 
    } 
    </script> 

    <form> 
    <form id="inputText"> 
    <input type="text" name="text here" value="write here" size= 100 
    value=40> 
    <input type="button" 
    onclick="sumbitFunction() " value="Go" 
    </form> 
    </body> 
    </html> 
+0

一個良好的開端,至少在HTML/JS的問題,使用jsbin.com或jsfiddle.net使其他人更容易開始使用您的代碼。 – abathur

回答

1

你可以做這樣的事情:

https://jsfiddle.net/Lvd5ecqu/1/

<html> 
    <head> 
     <title> Alphabetizer</title> 
    </head> 
     <script type="text/javascript"> 
      var submitFunction = function() { 
      var words = document.getElementById("words").value.split(" "); 
      var input = words.sort(); 
      document.getElementById("output").innerHTML = input.join(); 
      } 
     </script> 
    <body> 
     <p id="output"></p> 
     <form> 
      <form id="inputText"> 
       <input id="words" type="text" name="text here" value="write here" size= 100 value=40> 
       <input type="button" onclick="submitFunction() " value="Go" /> 
     </form> 
    </body> 
</html> 
+0

你的小提琴在輸入大小上有1和00之間的空格 – Steve