Guest User

Untitled

a guest
Feb 17th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. $('#idcaso').on('change', function (e) {
  2. e.preventDefault()
  3.  
  4. var valor= $('#idcaso option:selected').val()
  5.  
  6. var url=`/actdiarias/json/${valor}`;
  7.  
  8. console.log(url)
  9. fetch(url)
  10. .then(res => res.json())
  11. .then(datos =>{
  12. $('#genid').val(datos._id);
  13. $('#tienda').val(datos.tienda.nombre);
  14. $('#statustitulo').val(datos.status.titulo)
  15. $('#statusdescripcion').val(datos.status.descripcion)
  16.  
  17. var creatabla1 = `<table id= "tb" class="table table-striped table-sm">
  18. <thead>
  19. <tr>
  20. <th scope="col">#</th>
  21. <th scope="col">Articulo <strong class="text-black bg-warning"> selecciona un articulo! </strong></th>
  22. <th scope="col">Codigo</th>
  23. <th scope="col">Reporte</th>
  24. <th scope="col">id</th>
  25. <th scope="col">operacion</th>
  26.  
  27.  
  28. </tr>
  29. </thead>
  30. <tbody> </tbody>
  31. </table>`
  32.  
  33. $('#muestradetalle').append(creatabla1)
  34.  
  35. if (datos===null) {
  36. $('#muestradetalle').html('no se encontraron resultados...')
  37. console.log('no hayaste nada')
  38. return false;
  39. }
  40. var indice=0
  41. for (item in datos.articulos) {
  42. indice++
  43.  
  44. var creatabla = `
  45. <tr>
  46. <th scope="row">${[indice]}</th>
  47. <td>${datos.articulos[item].descripcion}</td>
  48. <td>${datos.articulos[item].codigo}</td>
  49. <td>${datos.articulos[item].reporte}</td>
  50. <td>${datos.articulos[item]._id}</td>
  51.  
  52. <td><button id="uhm"> explorar</button></td>
  53.  
  54. </tr>
  55. `
  56. $('#tb tbody').append(creatabla)
  57. }
  58.  
  59.  
  60. })
  61. .catch(err => console.log(err))
  62. $('#muestradetalle').empty().append('')
  63. });
  64. $('#uhm').on('click', function (e) {
  65. alert('hola')
  66. var seleccionado = datos.articulos.filter((articulo) => {
  67. if(articulo._id ===datos.articulos[item]._id){
  68. return true
  69. }
  70. else{
  71. return 'no encontrado'
  72. }
  73. console.log(seleccionado)
  74. })
Add Comment
Please, Sign In to add comment