Bueno les cuento que buscando googleando y foreando arme esto.
funciona con ENTER y va saltando de campo en campo, a su ves muestra otra fila.
Me gusto mucho espero que les sirva.
Dejo mas abajo el codigo, Ahora necesito:
Con javascript, Sumar can1 * uni1 y el resultado mostrarlo en sub1.
Algun scrip?
Codigo en formacion:
Código HTML:
Ver original<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=latin1"/> <script language="javascript"> function cambiarDisplay(id) {
if (!document.getElementById) return false;
fila = document.getElementById(id);
if (fila.style.display != "none") {
// fila.style.display = "none"; //ocultar fila
} else {
fila.style.display = ""; //mostrar fila
}
}
nextfield = "can1"; // name of first box on page
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");
function keyDown(DnEvents) { // handles keypress
// determines whether Netscape or Internet Explorer
k = (netscape) ? DnEvents.which : window.event.keyCode;
if (k == 13) { // enter key pressed
if (nextfield == 'done') return true; // submit, we finished all fields
else { // we're not done yet, send focus to next box
eval('document.yourform.' + nextfield + '.focus()');// ATENTOS Aca va el nombre del FORM
return false;
}
}
}
document.onkeydown = keyDown; // work together to analyze keystrokes
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
// End -->
<table width="100%" border="1"> <td><input name="can1" type="text" id="can1" size="2" maxlength="2" autocomplete="off" onFocus="nextfield ='cod1';" /></td> <td><input name="cod1" type="text" id="cod1" size="14" maxlength="13" autocomplete="off" onkeypress="cambiarDisplay('b')"onFocus="nextfield ='can2';" /></td> <td><input name="des1" type="text" id="des1" size="55" maxlength="50" autocomplete="off"/></td> <td><input name="uni1" type="text" id="uni1" size="6" maxlength="4" autocomplete="off"/></td> <td><input name="sub1" type="text" id="sub1" size="6" autocomplete="off" /></td> <tr id="b" style="display:none"> <td><input name="can2" type="text" id="can2" size="2" maxlength="2" autocomplete="off" onFocus="nextfield ='cod2';" /></td> <td><input name="cod2" type="text" id="cod2" size="14" maxlength="13" autocomplete="off" onkeypress="cambiarDisplay('c')" onFocus="nextfield ='can3';" /></td> <td><input name="des2" type="text" id="des2" size="55" maxlength="50" autocomplete="off"/></td> <td><input name="uni2" type="text" id="uni2" size="6" maxlength="4" autocomplete="off"/></td> <td><input name="sub2" type="text" id="sub2" size="6" autocomplete="off"/></td> <tr id="c" style="display:none"> <td><input name="can3" type="text" id="can3" size="2" maxlength="2" autocomplete="off" onFocus="nextfield ='cod3';" /></td> <td><input name="cod3" type="text" id="cod3" size="14" maxlength="13" autocomplete="off" onkeypress="cambiarDisplay('d')" onFocus="nextfield ='can4';" /></td> <td><input name="des3" type="text" id="des3" size="55" maxlength="50" autocomplete="off"/></td> <td><input name="uni3" type="text" id="uni3" size="6" maxlength="4" autocomplete="off"/></td> <td><input name="sub3" type="text" id="sub3" size="6" autocomplete="off"/></td> <tr id="d" style="display:none"> <td><input name="can4" type="text" id="can4" size="2" maxlength="2" autocomplete="off" onFocus="nextfield ='cod4';" /></td> <td><input name="cod4" type="text" id="cod4" size="14" maxlength="13" autocomplete="off" onFocus="nextfield ='done';"/></td> <td><input name="des4" type="text" id="des4" size="55" maxlength="50" autocomplete="off"/></td> <td><input name="uni4" type="text" id="uni4" size="6" maxlength="4" autocomplete="off"/></td> <td><input name="sub4" type="text" id="sub4" size="6" autocomplete="off" /></td> <center>
<input type=submit name=done value="Submit"> </center>