无法在div

时间:2017-04-14 03:09:02

标签: javascript html arrays loops sorting

Expected Output 我希望在单击按钮时数字看起来像矩阵,我不知道如何使用多维数组来获得预期的输出(单击蓝色链接)。有什么帮助吗?

<!DOCTYPE html>
<html>
<body>

<div class="rightDiv">
<div id = "pastcalcblock"> 
    <h3> PAST CALCULATIONS </h3>
         <input type = "text" size = "1" id = "text1"/>
         <input type = "text" size = "1" id = "text2"/>
         <input type = "text" size = "1" id = "text3"/>
         <input type = "text" size = "1" id = "text4"/><br>
         <input type = "button" value = "Ok" id = "operation" onClick = "display()"/>
         <div id = "resultTab">
                SORT<br>
                    <input type = "button" value = "As Entered" id = "enteredBut">
                    <input type = "button" value = "By Result" id = "resultBut"><br><br>
                    <div id = "expressions"></hr></div>                 
            </div>
        </div>

<script>
function display()
{
    var arrayOne =  [document.getElementById('text1').value,document.getElementById('text2').value,document.getElementById('text3').value,document.getElementById('text4').value ][];


    document.getElementById("expressions").innerHTML = arrayOne;
    var para = document.createElement("P");
    var t = document.createTextNode("arrayOne");
    para.appendChild(t);
    document.getElementById("expresions").appendChild(para);
}

</script>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

仅在没有[]

的情况下更正arrayOne

JSFiddle