Tema: ayuda
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/06/2010, 10:59
juanitoto
 
Fecha de Ingreso: septiembre-2009
Mensajes: 40
Antigüedad: 15 años, 4 meses
Puntos: 0
ayuda

Hola
Soy muy novato en javascript ojala me puedan ayudar..
mi cuestion es la siguiente:

este es la pagina pedido.htm

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script language="JavaScript">
  4. function cambiarTalle()
  5. {
  6. document.itemsform.text3.value =
  7. document.itemsform.newTalle.options [document.itemsform.newTalle.selectedIndex].value;
  8. document.itemsform.text2.value =
  9. document.itemsform.newTalle.options[document.itemsform.newTalle.selectedIndex].text;
  10. }
  11. </script>
  12.  
  13. <SCRIPT LANGUAGE="JavaScript">
  14. function buyItem(newItem, newPrice, newQuantity, newTalle) {
  15.         if (newQuantity <= 0) {
  16.             rc = alert('La cantidad ingresada es incorrecta'); 
  17.             return false;
  18.             }
  19.             if(document.getElementById('talleSelect').value==0 ){
  20. alert ('Debe escoger un talle');
  21. return 0;
  22. }
  23. if(document.getElementById('talleSelect').value==25 ){
  24. newQuantity=8;
  25. }
  26. if (confirm('¿Agregar '+newQuantity+' '+newItem+' '+newTalle+' al pedido?')) {
  27.             index = document.cookie.indexOf("TheBasket");
  28.             countbegin = (document.cookie.indexOf("=", index) + 1);
  29.                 countend = document.cookie.indexOf(";", index);
  30.       if (countend == -1) {
  31. countend = document.cookie.length;
  32.                 }
  33. document.cookie="TheBasket="+document.cookie.substring(countbegin, countend)+"["+newItem+"/"+newTalle+","+newPrice+"#"+newQuantity+"]";
  34.         }
  35.         return true;
  36.         }
  37. </SCRIPT>
  38.  
  39. <form NAME="itemsform" >
  40.        
  41. <select size="1" name="newTalle" onChange="cambiarTalle()" id="talleSelect">
  42.           <option value="0" selected>Talle</option>
  43.           <option value="26">T1bb</option>
  44.           <option value="26">T2bb</option>
  45.           <option value="27">T2</option>
  46.           <option value="27">T4</option>
  47.           <option value="28">T6</option>
  48.           <option value="28">T8</option>
  49.           <option value="29">T10</option>
  50.           <option value="29">T12</option>
  51.           <option value="25">Curva</option>
  52.      </select>
  53. <input name="text2" type="text" style="border:0;" size="2" >$
  54. <input name="text3" type="text" style="border:0;" size="2">    
  55. <input type="button" name="cbtadd2" value="Agregar" onClick="buyItem('Art0766',document.itemsform.newTalle.value,document.itemsform.agregar1.value,document.itemsform.text2.value)">
  56. </form>
  57. </body>
  58. </html>

mi consulta es la siguiente:

cuando el usuario escoje

1 curva
Código Javascript:
Ver original
  1. <option value="25">Curva</option>
se agregue la cantidad de 8

que lo hice asi:

Código Javascript:
Ver original
  1. if(document.getElementById('talleSelect').value==25 ){
  2. newQuantity=8;
  3. }
y funciona bien,

el tema esta cuando yo quiero agregar

2 curvas que me agregue la cantidad 16
3 curvas que me agruegue la cantidad 24

y asi continuamente...

como tendria que hacer?¿

desde ya muchas gracias!