Guest User

Untitled

a guest
Jul 15th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. function sig12(){
  2.  
  3. var array = new Array(" Disponible ", " Ocupado ", " Mantenimiento ",);
  4.  
  5. for(i=0; i < array.length; i++){
  6. if(document.getElementById('este12').value == array[i]){
  7. var indice = (i + 1 == array.length) ? 0 : i + 1;
  8. document.getElementById('este12').value = array[indice];
  9. localStorage.setItem("estado12", array[indice]);
  10. break;
  11. }
  12. }
  13. }
  14.  
  15. window.onload=function()
  16. {
  17.  
  18. if(localStorage.getItem("estado")!=null)
  19. {
  20. estado12 =localStorage.getItem("estado12");
  21. document.getElementById('este12').value = estado12;
  22. }
  23. }
  24.  
  25. <div class="span2">
  26. <div class="well well-small">
  27. <h4 >Habitación 12</h4>
  28. <input id="este12" type="button" value=" Disponible " onclick="sig12()" />
  29. <br>
  30. <a href="habitacion1.php"><small>Alquilar</small></a>
  31. </div>
  32. </div>
  33.  
  34. <div id='container'></div>
  35. <center><input id="crear1" type="button" value=" Añadir habitación "
  36. onclick="crear()" /></center>
  37.  
  38. var i = 0;
  39.  
  40. function crear() {
  41.  
  42. var array = new Array(" Disponible ", " Ocupado ", " Mantenimiento ");
  43. if (i + 1 < array.length) {
  44. i++;
  45. crearDivs(array[i], array);
  46. } else {
  47. i = 0;
  48. crearDivs(array[i], array);
  49. }
  50. }
  51.  
  52. function crearDivs(nameDiv, array) {
  53. let divNuevo = document.createElement('div');
  54. divNuevo.classList.add('divs');
  55. divNuevo.innerHTML = nameDiv;
  56.  
  57. document.getElementById('container').appendChild(divNuevo);
  58. document.getElementById('crear1').value = array[i];
  59. }
  60.  
  61. .divs {
  62. float: left;
  63. width: 140px;
  64. height: 110px;
  65. background: white;
  66. margin-left: 20px;
  67. color: black;
  68.  
  69. }
Add Comment
Please, Sign In to add comment