Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/03/2012, 20:35
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: necesito codigo.. numero aleatorio cada vez qe actualiza la pagina.

Tu planteo no me es muy claro, yo estuve jugando con la script e hice esto
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>Números aleatorios únicos en botones</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <style type="text/css">
  7. /*<![CDATA[*/
  8. input[type='button']{
  9. width: 30px;
  10. height: 30px;
  11. padding: 2px;
  12. margin: 1px;
  13. }
  14. /*]]>*/
  15. <script type="text/javascript">
  16. //<![CDATA[
  17. var mezclar = function(n){
  18.  for(var j, x, i = n.length; i; j = parseInt(Math.random() * i), x = n[--i], n[i] = n[j], n[j] = x);
  19.  return n;
  20. };
  21. //]]>
  22. <script type="text/javascript">
  23. //<![CDATA[
  24. function escribe_numeros(r){
  25. var secuencia = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  26. var cadena = mezclar(secuencia).toString();
  27. var numeros = new Array();
  28. numeros=cadena.split(",");
  29. var f = 0;
  30. var m;
  31. for (m=0;m<numeros.length;m++){
  32. var campo = 'b_' + f;
  33. document.getElementById(campo).disabled = false;
  34. if(r != 'no'){
  35. document.getElementById(campo).value = numeros[m];
  36. }
  37. f++;
  38. }
  39.  
  40. document.getElementById('visor').value = "";
  41. }
  42.  
  43. function rellenar(v,idc){
  44. var c=document.getElementById("visor").value;
  45. c=c+v;
  46. document.getElementById("visor").value= c;
  47. document.getElementById(idc).disabled = true;
  48. }
  49. function reiniciar(){
  50. document.getElementById("visor").value= '';
  51. escribe_numeros();
  52. }
  53. function limpiar(){
  54. document.getElementById("visor").value= '';
  55. escribe_numeros('no');
  56. }
  57. //]]>
  58. </head>
  59. <body onload="escribe_numeros();">
  60. <div style="margin-top: 20px;">
  61. <form action="#">
  62. <input type="text" value="" readonly="readonly" id="visor" maxlength="10"/><br /><br />
  63.  
  64. <input type="button" onclick="rellenar(this.value,this.id);" value="1" id="b_1" /> <input type="button" onclick="rellenar(this.value,this.id);" value="2" id="b_2" /> <input type="button" onclick="rellenar(this.value,this.id);" value="3" id="b_3" /> <br />
  65. <input type="button" onclick="rellenar(this.value,this.id);" value="4" id="b_4" /> <input type="button" onclick="rellenar(this.value,this.id);" value="5" id="b_5" /> <input type="button" onclick="rellenar(this.value,this.id);" value="6" id="b_6" /> <br />
  66. <input type="button" onclick="rellenar(this.value,this.id);" value="7" id="b_7" /> <input type="button" onclick="rellenar(this.value,this.id);" value="8" id="b_8" /> <input type="button" onclick="rellenar(this.value,this.id);" value="9" id="b_9" /> <br />
  67. <input type="button" onclick="rellenar(this.value,this.id);" value="0" id="b_0" /> <input type="button" onclick="limpiar();" value="C" title="establece a cero con los números actuales" /> <input type="button" onclick="reiniciar();" value="R" title="reinicia y mezcla" />
  68. </form>
  69. </div>
  70. </body>
  71. </html>

Ahi están las posibilidaes que se me ocurrieron. Fijate que podés rescatar

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.