parent
6cbc2d4497
commit
c2a6f5a416
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<script src="script.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button onclick="addStudent()">add student</button>
|
||||||
|
|
||||||
|
<form id="add">
|
||||||
|
<label>name</label>
|
||||||
|
<input type="text" id="addName"/>
|
||||||
|
<label>weight</label>
|
||||||
|
<input type="text" id="addWeight"/>
|
||||||
|
<label>height</label>
|
||||||
|
<input type="text" id="addHeight"/>
|
||||||
|
<label>hair colour</label>
|
||||||
|
<input type="text" id="addHairColour"/>
|
||||||
|
<label>gpa</label>
|
||||||
|
<input type="text" id="addGpa"/>
|
||||||
|
<button id="submitStudent" onclick="addData()">submit</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,24 @@
|
|||||||
|
window.onload=function(){
|
||||||
|
addForm=document.getElementById("add");
|
||||||
|
addForm.style.display="none";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addStudent(){
|
||||||
|
console.log("add student");
|
||||||
|
form=document.getElementById("add");
|
||||||
|
form.style.display="block";
|
||||||
|
}
|
||||||
|
|
||||||
|
function addData(){
|
||||||
|
var name=document.getElementById("addName").value;
|
||||||
|
var weight=document.getElementById("addWeight").value;
|
||||||
|
var height=document.getElementById("addHeight").value;
|
||||||
|
var hairColour=document.getElementById("addHairColour").value;
|
||||||
|
var gpa=document.getElementById("addGpa").value;
|
||||||
|
var data={name, weight, height, hairColour, gpa};
|
||||||
|
var option={method:"POST", body: JSON.stringify(data), headers:{'Content-Type':'application/json'}};
|
||||||
|
console.log(option);
|
||||||
|
fetch('/student', option);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue