25 lines
942 B
HTML
25 lines
942 B
HTML
|
<html>
|
||
|
<body>
|
||
|
<form id="form" method="post">
|
||
|
<h1>Test out my cool program 😎</h1>
|
||
|
<p>A software tester walks into a bar and orders <input type="text" id="beerCount" name="beerCount" /> beers</p>
|
||
|
<button type="submit">Submit</button>
|
||
|
</form>
|
||
|
<script>
|
||
|
function submit(event) {
|
||
|
event.preventDefault();
|
||
|
const beerCount = document.getElementById("beerCount").value;
|
||
|
fetch("http://localhost:3001", {
|
||
|
method: 'POST',
|
||
|
body: beerCount.toString(),
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
}
|
||
|
})
|
||
|
alert("The backend will now validate ur answer :)")
|
||
|
}
|
||
|
|
||
|
//document.getElementById("form").addEventListener("submit", submit, true)
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|