Skip to content

Instantly share code, notes, and snippets.

@liorama
Created February 13, 2018 00:04
Show Gist options
  • Save liorama/f5d4ff3e7465a0bd52cad9a3e1840caa to your computer and use it in GitHub Desktop.
Save liorama/f5d4ff3e7465a0bd52cad9a3e1840caa to your computer and use it in GitHub Desktop.
Mock html poll
<!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