Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/06/2010, 14:53
juanitoto
 
Fecha de Ingreso: septiembre-2009
Mensajes: 40
Antigüedad: 14 años, 8 meses
Puntos: 0
error en formulario

Hola ! a ver si alguien me ayuda..
tengo el siguiente problema..
este codigo se encuentra en la pagina pedido.htm
son 2 formularios
si yo primero quiero usar el FORMULARIO 2 y poner por ejemplo talle4 me tira el alert 'Debe escoger un talle' ...
pero cuando elijo alguna opcion del FORMULARIO 1 y luego elijo una opcion del FORMULARIO 2 ya no me tira el alert 'Debe escoger un talle' y me agrega el articulo correctamente
que es lo que esta pasando?¡



Código Javascript:
Ver original
  1. <script language="JavaScript">
  2. function cambiarTalle()
  3. {
  4.    document.itemsform.text3.value =
  5.      document.itemsform.newTalle.options [document.itemsform.newTalle.selectedIndex].value;
  6. document.itemsform.text32.value =
  7.      document.itemsform.newTalle2.options [document.itemsform.newTalle2.selectedIndex].value;
  8.        
  9.      
  10.  document.itemsform.text2.value =
  11.      document.itemsform.newTalle.options[document.itemsform.newTalle.selectedIndex].text;
  12.          document.itemsform.text22.value =
  13.      document.itemsform.newTalle2.options[document.itemsform.newTalle2.selectedIndex].text;
  14.  
  15.  }
  16. </script>
  17.  
  18.  
  19. <SCRIPT LANGUAGE="JavaScript">
  20.  
  21.     function buyItem(newItem, newPrice, newQuantity, newTalle) {
  22.        
  23.         if(document.getElementById('talleSelect').value==0 ){
  24. alert ('Debe escoger un talle');
  25. return false;
  26. }
  27.        
  28.         if (newQuantity <= 0) {
  29.             rc = alert('La cantidad ingresada es incorrecta'); 
  30.             return false;
  31.             }
  32.            
  33.        
  34.         if (document.getElementById('talleSelect').selectedIndex==9 && !isNaN(document.getElementById('multiplicar').value)){
  35.  newQuantity=8*document.getElementById('multiplicar').value;
  36. }
  37.  
  38.    
  39.            
  40.         if (confirm('¿Agregar '+newQuantity+' '+newItem+' '+newTalle+' al carrito?')) {
  41.             index = document.cookie.indexOf("TheBasket");
  42.             countbegin = (document.cookie.indexOf("=", index) + 1);
  43.                 countend = document.cookie.indexOf(";", index);
  44.                 if (countend == -1) {
  45.                         countend = document.cookie.length;
  46.                 }
  47.                     document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"/"+newTalle+","+newPrice+"#"+newQuantity+"]";
  48.         }
  49.         return true;
  50.     }
  51.  
  52.     function resetShoppingBasket() {
  53.         index = document.cookie.indexOf("TheBasket");
  54.         document.cookie="TheBasket=.";
  55.     }  
  56. </SCRIPT>

FORMULARIO 1:

Código Javascript:
Ver original
  1. <form NAME="itemsform" >
  2.       <input TYPE= "value" NAME="agregar1" VALUE="1" SIZE="3" id="multiplicar">    
  3.       <select size="1" name="newTalle" onChange="cambiarTalle()" id="talleSelect">
  4.           <option value="0" selected>Talle</option>
  5.           <option value="26">T1bb</option>
  6.           <option value="26">T2bb</option>
  7.           <option value="27">Talle2</option>
  8.           <option value="27">Talle4</option>
  9.           <option value="28">Talle6</option>
  10.           <option value="28">Talle8</option>
  11.           <option value="29">Talle10</option>
  12.           <option value="29">Talle12</option>
  13.           <option value="25">Curva</option>
  14.           </select>
  15.             <input name="text2" type="text" style="border:0;" size="2" >
  16.             $
  17.             <input name="text3" type="text" style="border:0;" size="2">
  18.        
  19.             <input type="button" name="cbtadd2" value="Agregar"
  20.       onClick="buyItem('Art0766',document.itemsform.newTalle.value,document.itemsform.agregar1.value,document.itemsform.text2.value)">

FORMULARIO 2:

Código Javascript:
Ver original
  1. <input TYPE= "value" NAME="agregar11" VALUE="1" SIZE="3" id="multiplicar"> <select size="1" name="newTalle2" onChange="cambiarTalle()" id="talleSelect">
  2.           <option value="0" selected >Talle</option>
  3.           <option value="26">T1bb</option>
  4.           <option value="26">T2bb</option>
  5.           <option value="27">Talle2</option>
  6.           <option value="27">Talle4</option>
  7.           <option value="28">Talle6</option>
  8.           <option value="28">Talle8</option>
  9.           <option value="29">Talle10</option>
  10.           <option value="29">Talle12</option>
  11.           <option value="25">Curva</option>
  12.    
  13.       </select>
  14.             <input name="text22" type="text" style="border:0;" size="2" >$
  15.             <input name="text32" type="text" style="border:0;" size="2">
  16.          
  17. <input type="button" name="cbtadd22" value="Agregar" onClick="buyItem('Art0766',document.itemsform.newTalle2.value,document.itemsform.agregar11.value,document.itemsform.text22.value)" >
  18.       </form>