Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/02/2011, 13:35
CWeeD
 
Fecha de Ingreso: octubre-2010
Mensajes: 136
Antigüedad: 13 años, 6 meses
Puntos: 4
De acuerdo Respuesta: Selección aleatoria en Combobox?

Gracias...ya lo solucione, y agregue un poquito mas...pero gracias por tu pronta respuesta...Aqui les dejo el código que emplee, y una pequeña animaciónen el mismo...

Código Javascript:
Ver original
  1. var animation={
  2.  
  3. navigate:function(selectId){
  4.     this.selectObj=document.getElementById(selectId)
  5.     window.location=this.selectObj[this.selectObj.selectedIndex].value
  6. },
  7.  
  8. randomizeInit:function(selectId){
  9.     this.selectObj=document.getElementById(selectId)
  10.     this.curframe=0
  11.     this.optionscount=this.selectObj.options.length
  12.  //calculate number of frames to animate (cycle through options before settling on one)
  13.     this.maxframes=Math.floor(Math.random()*this.optionscount)+Math.floor(Math.random()*this.optionscount)
  14.     this.randomize()
  15. },
  16.  
  17.  
  18. randomize:function(){
  19.     if (this.curframe<this.maxframes)
  20.         this.selectObj.selectedIndex=this.settledIndex=(this.curframe<this.optionscount)? this.curframe : this.curframe-this.optionscount
  21.     else{ //settle on and select this option
  22.         this.selectObj.selectedIndex=(this.selectObj.selectedIndex==-1)? this.settledIndex : -1
  23.     }
  24.     this.curframe++
  25.     if (this.curframe<this.maxframes+4)
  26.         setTimeout("animation.randomize()", 100)
  27.    
  28.     }
  29.  
  30. }

Como viste emple el código que me diste y trabaje a partir del mismo...gracias de verdad...
ahora solo queda disparar la función como mejor se acomode, en el body con onLoad= para dispararla cuando se carga la página aunque creo que ya sabían eso jeje, y si no con onClick= en un botón...hay les queda...se llama de esta forma "animation.randomizeInit('aqui el id')"
Solo que ahora el problema es que son dos combobox, y el segundo se llena apartir del primero, antes llamaba la funcion con onChange en el combo pero como ahora no hago click en ella ni hago ningún cambio, no se dispara la funcion para llenar el segundo combo hasta que haga click sobre la opcion...