Skip to content
Snippets Groups Projects
Commit 9f5e2bf6 authored by Stegge, M.D.F. aan de (Marten, Student B-BIT)'s avatar Stegge, M.D.F. aan de (Marten, Student B-BIT)
Browse files

Create Trainer page added

parent d0be79bd
Branches main
No related tags found
No related merge requests found
......@@ -15,16 +15,30 @@
</head>
<body>
<h1>Create Trainer</h1>
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br>
<button>Submit</button>
<form id="trainerform">
Name:
<input type="text" name="name" id="nameID"><br>
<input type="submit" value="Submit">
</form>
</body>
<script>
async function submitForm(event){
event.preventDefault();
const name = document.getElementById('nameID').value
await fetch('/pokemon/api/trainers', {
method: 'POST',
body: JSON.stringify({name: name}),
headers: {
"content-type" : "application/json"
}
})
console.log(name);
window.location.href = 'trainerTypes.html';
}
const form = document.getElementById('trainerform');
form.addEventListener('submit', submitForm);
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment