将javascript弹出框输入存储在数组中,并按字母顺序显示

将javascript弹出框输入存储在数组中,并按字母顺序显示,javascript,Javascript,从提示框中将名称作为输入。提示框应继续询问 命名,直到弹出窗口上的复选框显示“阻止附加对话框”为止 选中的。然后按字母顺序显示名称,这些名称是 通过提示框输入 <!DOCTYPE html> <html> <body> <p>Click the button to demonstrate the prompt box.</p> <button onclick="myFunction()">Try it&l

从提示框中将名称作为输入。提示框应继续询问 命名,直到弹出窗口上的复选框显示“阻止附加对话框”为止 选中的。然后按字母顺序显示名称,这些名称是 通过提示框输入

  <!DOCTYPE html>
  <html>
   <body>

<p>Click the button to demonstrate the prompt box.</p>

 <button onclick="myFunction()">Try it</button>

 <p id="demo"></p>

  <script>
  function myFunction() {
 while(true)
       {
   var person = prompt("Please enter your name");
    }  
   var i=0;
     while(i<person.length)
     {
     if (person[i] != null) {
     document.getElementById("demo").innerHTML =person[i]
     }
    i++;
       }
     }
      </script>

    </body>
      </html>
单击按钮以演示提示框

  <!DOCTYPE html>
  <html>
   <body>

<p>Click the button to demonstrate the prompt box.</p>

 <button onclick="myFunction()">Try it</button>

 <p id="demo"></p>

  <script>
  function myFunction() {
 while(true)
       {
   var person = prompt("Please enter your name");
    }  
   var i=0;
     while(i<person.length)
     {
     if (person[i] != null) {
     document.getElementById("demo").innerHTML =person[i]
     }
    i++;
       }
     }
      </script>

    </body>
      </html>
试试看

var计数=-1; 函数myFunction{ var person_names=新数组; 做{ 计数++; 人名[计数]=提示请输入您的姓名,Naeem; var i=0; 变量人员名称列表=; 如果人名[计数]==null | |人名[计数]==| |人名[计数]== { 打破 } }whileperson_names[count]!=null; 人名。倒数;
当您忘记包含代码时。您尝试了什么?您可以使用person_names.sort函数而不是person_names.reverse;若要按数组的字母升序排列,则该按钮在任何浏览器上都没有响应。现在它正在工作<符号在条件下不工作,而由于堆栈溢出权限,它被隐藏让我们现在检查更新一个