Created
February 13, 2018 00:04
-
-
Save liorama/f5d4ff3e7465a0bd52cad9a3e1840caa to your computer and use it in GitHub Desktop.
Mock html poll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<style> | |
.item { | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
<form> | |
<div class="item"><input id="q1a1" type="radio" name="question1" value="answer1"><label for="q1a1">answer1</label></div> | |
<div class="item"> | |
<input id="q1a2" type="radio" name="question1" value="answer2"><label for="q1a2">answer2</label> | |
</div> | |
<div class="item"> | |
<input id="q1a3" type="radio" name="question1" value="answer3"><label for="q1a3">answer3</label> | |
</div> | |
<div class="item"> | |
<input id="q1a4" type="radio" name="question1" value="answer4"><label for="q1a4">answer4</label> | |
</div> | |
<div class="item"> | |
<button type="submit">Submit</button> | |
</div> | |
</form> | |
</div> | |
<script> | |
var form = document.querySelector("form"); | |
form.addEventListener("submit", function (e) { | |
e.preventDefault(); | |
var data = new FormData(form); | |
var result = {}; | |
for (const entry of data) { | |
result[entry[0]] = entry[1] | |
} | |
console.log(result); | |
kin.ecosystem.offer.submitResponse(result); | |
}, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment