Ver Mensaje Individual
  #34 (permalink)  
Antiguo 10/11/2008, 14:04
Avatar de hoberwilly
hoberwilly
 
Fecha de Ingreso: julio-2008
Ubicación: Lima - Perú
Mensajes: 769
Antigüedad: 16 años, 7 meses
Puntos: 2
Respuesta: Envio de mensaje js al no haber stock disponible

Es asi que los campo de texto que tengo los valores los tengo asi:

<form name="a<?php echo $v['identificador'] ?>" method="post" action="agregacarrito2.php?<?php echo SID ?>" id="a<?php echo $v['identificador'] ?>" onsubmit="return checked('this.text');"> //como implementar el onsubmit
<td align="center"><input type="text" name="cantidad_autorizada" id="cantidad" value=" " size="4" maxlength='6'></td>
<td align="right"><input type="button" name="stock_disponible" value=<?php echo $row2['stock']; ?>></td>
<td><input type="submit" value="Autorizar"></td>
</form>

y el js es:
function checked(text) {
for (i=0; i<text.length; i++) { //tengo que recorrer todos los campos de texto (cantidad_autorizada)
var canti_soli = document.getElement.ById('cantidad_autorizada').va lue;
var stock_dispo = document.getElement.ById('stock_disponible').value ;
if (canti_soli<stock_dispo) {
return true;
}
}
alert("stock deficiente");
return false;
}

Agradesco sus colaboraciones...