68 lines
1.8 KiB
Plaintext
68 lines
1.8 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>test</title>
|
|
<style>
|
|
form > group{
|
|
margin: 10px 0;
|
|
display: block;
|
|
}
|
|
group * {
|
|
display: block;
|
|
}
|
|
</style>
|
|
<script src="/static/serializer.js"></script>
|
|
</head>
|
|
<body>
|
|
<form id="testform">
|
|
{{ range $k, $p := . }}
|
|
{{ if $p }}
|
|
<group name="[{{ $k }}]">
|
|
<input value="something without a name">
|
|
<input name="name" type="text" value="{{ $p.Name }}">
|
|
<input name="surname" type="text" value="{{ $p.Surname }}">
|
|
<input name="age" type="number" value="{{ $p.Age }}">
|
|
<input name="birth_date" type="date" value="{{ $p.BirthDate.Format "2006-01-02" }}">
|
|
{{ range $p.Languages }}
|
|
<group name="[]languages">
|
|
<label>
|
|
<input name="language" type="text" value="{{ .Language }}">
|
|
</label>
|
|
<input name="native" type="checkbox" {{ if .Native }} checked {{ end }}>
|
|
<input name="skill_level" type="number" value="{{ .SkillLevel }}">
|
|
</group>
|
|
{{ end }}
|
|
<select multiple name="checklist">
|
|
<option selected value="Milk">Milk</option>
|
|
<option value="Eggs">Eggs</option>
|
|
</select>
|
|
<select multiple name="json">
|
|
<option selected name="key" value="value">Value</option>
|
|
</select>
|
|
<select name="animal">
|
|
<option value="Dog" selected>Dog</option>
|
|
<option value="Cat">Cat</option>
|
|
</select>
|
|
</group>
|
|
{{ end }}
|
|
{{ end }}
|
|
</form>
|
|
<script>
|
|
let f = document.getElementById("testform"),
|
|
s = new Serializer(f);
|
|
|
|
fetch("/", {
|
|
method: 'post',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify(s.serialize())
|
|
}).then(() => {
|
|
window.close()
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|