| 1 | <!DOCTYPE html> |
| 2 | <html lang="es"> |
| 3 | |
| 4 | <head> |
| 5 | |
| 6 | <meta charset="UTF-8"> |
| 7 | <meta name="viewport" |
| 8 | content="width=device-width"> |
| 9 | |
| 10 | <title>Modificar</title> |
| 11 | |
| 12 | <script type="module" src="lib/js/consumeJson.js"></script> |
| 13 | <script type="module" src="lib/js/submitForm.js"></script> |
| 14 | <script type="module" src="lib/js/muestraObjeto.js"></script> |
| 15 | <script type="module" src="lib/js/muestraError.js"></script> |
| 16 | |
| 17 | <script> |
| 18 | |
| 19 | const params = new URL(location.href).searchParams |
| 20 | </script> |
| 21 | |
| 22 | </head> |
| 23 | |
| 24 | <body onload="if (params.size > 0) { |
| 25 | consumeJson('srv/pasatiempo.php?' + params) |
| 26 | .then(respuesta => muestraObjeto(forma, respuesta.body)) |
| 27 | .catch(muestraError) |
| 28 | }"> |
| 29 | |
| 30 | <form id="forma" onsubmit="submitForm('srv/pasatiempo-modifica.php', event) |
| 31 | .then(respuesta => location.href = 'index.html') |
| 32 | .catch(muestraError)"> |
| 33 | |
| 34 | <h1>Modificar</h1> |
| 35 | |
| 36 | <p><a href="index.html">Cancelar</a></p> |
| 37 | |
| 38 | <input name="id" type="hidden"> |
| 39 | |
| 40 | <p> |
| 41 | <label> |
| 42 | Nombre * |
| 43 | <input name="nombre" value="Cargando…"> |
| 44 | </label> |
| 45 | </p> |
| 46 | |
| 47 | <p>* Obligatorio</p> |
| 48 | |
| 49 | <p> |
| 50 | |
| 51 | <button type="submit">Guardar</button> |
| 52 | |
| 53 | <button type="button" onclick=" |
| 54 | if (params.size > 0 && confirm('Confirma la eliminación')) { |
| 55 | consumeJson('srv/pasatiempo-elimina.php?' + params) |
| 56 | .then(() => location.href = 'index.html') |
| 57 | .catch(muestraError) |
| 58 | }"> |
| 59 | Eliminar |
| 60 | </button> |
| 61 | |
| 62 | </p> |
| 63 | |
| 64 | </form> |
| 65 | |
| 66 | </body> |
| 67 | |
| 68 | </html> |