jogieglenmait 0 Light Poster

how do i print a 2d array in a javascript without leaving the form. because whenever i click a button, an element is added to the array but it shows it in a different page

here is my code

function addNumbers2Array()
{
    MultiArray [x] = new Array(6)
    MultiArray[x][0] = parseInt(document.getElementById("latitude").value);
    MultiArray[x][1] = parseInt(document.getElementById("longitude").value);
    MultiArray[x][2] = parseInt(document.getElementById("altitude").value);
    MultiArray[x][3] = parseInt(document.getElementById("header").value);
    MultiArray[x][4] = parseInt(document.getElementById("tilt").value);
    MultiArray[x][5] = parseInt(document.getElementById("range").value); 

    document.getElementById("reslatitude").value = MultiArray[x][0];
    document.getElementById("reslongitude").value = MultiArray[x][1];
    document.getElementById("resaltitude").value = MultiArray[x][2];
    document.getElementById("resheader").value = MultiArray[x][3];
    document.getElementById("restilt").value = MultiArray[x][4];
    document.getElementById("resrange").value = MultiArray[x][5];

    x++;
    y=x;

    for (var w=0;w<x;w++)
    {
    document.write("lat: " + MultiArray[w][0] +
                    " lon: " + MultiArray[w][1] +
                    " alt: " + MultiArray[w][2] +
                    " hed: " + MultiArray[w][3] +
                    " til: " + MultiArray[w][4] +
                    " ran: " + MultiArray[w][5]);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.