I am creating a program that captures data on a page using JavaScript. I inserted the QuickSort sorting method for general queries, however, only one query is displayed on the screen even if I entered more than one.
This is my code:
var menu;
var opccon;
var opccan;
var activo = [];
var activo = new Array();
var nombre = [];
var x = 0;
var y = 0;
var i = 0;
var xnum;
var Tr = 1;
var num = [];
var num = new Array();
var renglon = 0;
var encontro = 0;
var min = 0;
do {
menu = prompt("MENU PRINCIPAL \n 1.-Captura \n2.-Consulta \n3.-Actualizaciones \n4.-Cancelaciones \n5.-Salida");
if (menu == 1) {
activo = 0;
xnum = prompt("Ingrese su Numero contable");
for (x = 1; x <= renglon; x++) {
if (xnum == num[x]) {
encontro = 1;
}
}
if (encontro == 0) {
renglon = 0;
for (x = 1; x <= renglon; x++) {
if (num[x] != null) {
renglon = renglon + 1;
}
}
renglon = renglon + 1;
num[renglon] = xnum;
nombre[renglon] = prompt("Ingrese su NOMBRE");
activo[renglon] = 1;
}
if (encontro == 1) {
alert("Registro ya existente intente con otro registro");
}
}
if (menu == 2) {
do {
opccon = prompt("MENU PRINCIPAL \n 1.-Registro \n2.-General \n3.-Regresar");
if (opccon == 1) {
encontro;
xnum = prompt("Ingresa el numero de cuenta que desea encontrar")
for (x = 1; x <= renglon; x++) {
if (xnum == num[x]) {
encontro = 1;
alert("Nombre " + nombre[x] + " Numero de cuenta " + num[x]);
}
}
if (encontro == 0) {
alert("Disculpe el numero que ingreso no esta en la base de datos ");
}
}
if (opccon == 2) {
function stableSort(v, f) {
if (f === undefined) {
f = function(a, b) {
a = "" + a;
b = "" + b;
return a < b ? -1 : (a > b ? 1 : 0);
}
}
var dv = [];
for (var i = 0; i < v.length; i++) {
dv[i] = [v[i], i];
}
dv.sort(function(a, b) {
return f(a[0], b[0]) || (a[1] - b[1]);
});
for (var i = 0; i < v.length; i++) {
v[i] = dv[i][0];
}
}
num.sort();
for (x = 1; x <= renglon; x++) {
alert("Clave: " + num + "\n" + "Nombre: " + nombre);
}
}
} while (opccon != 3);
}
if (menu == 3) {
encontro = 1;
xnum = prompt("Ingresa el numero de cuenta que desea encontrar");
for (x = 1; x <= renglon; x++) {
if (xnum == num[x]) {
encontro = 1;
alert("Nombre: " + nombre[x] + " Numero de cuenta: " + num[x]);
nombre[x] = prompt("Digite de nuevo el Nombre");
alert("Nombre cambiado");
}
}
if (encontro == 0)
{
alert("Disculpe el numero que ingreso no esta en la base de datos");
}
}
if (menu == 4) {
do {
opccan = prompt("MENU \n 1.-Fisicas \n2.-Logicas \n3.-Reinstalaciones \n4.-Regresar");
if (opccan == 1) {
encontro = 0;
xnum = prompt("Ingrese número");
for (x = 1; x <= renglon; x++) {
if (xnum == num[x]) {
encontro = 1;
alert("Nombre " + nombre[x] + " Numero de cuenta " + num[x] + "será eliminado");
num[x] = 0;
nombre[x] = null;
xnum[x] = null;
activo[x] = 0;
}
}
if (encontro == 0) {
alert("No se encontro el registro ingresado ");
}
}
if (opccan == 2) {
xnum = prompt("Ingrese número");
for (x = 1; x <= renglon; x++) {
if (xnum == num[x]) {
alert("Nombre " + nombre[x] + " Numero de cuenta " + num[x] + " será eliminado");
activo[x] = 0;
}
}
}
if (opccan == 3) {
xnum = prompt("Ingrese número");
for (x = 1; x <= 10; x++) {
if (xnum == num[x]) {
if (activo[x] == 0) {
activo[x] = 1;
}
}
}
}
} while (opccan != 4);
}
} while (menu != 5);
<title>Documento sin título</title>