Skip to content

Instantly share code, notes, and snippets.

@akira02
Created March 2, 2022 16:38
Show Gist options
  • Save akira02/3f5f1b8bf40f14c4a36c6365e1680527 to your computer and use it in GitHub Desktop.
Save akira02/3f5f1b8bf40f14c4a36c6365e1680527 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="zh-TW">
<form name="form" id="form">
<label for="test1">test1</label>
<select name="test1">
<option>Dog</option>
<option>Cat</option>
<option>Hamster</option>
<option>Parrot</option>
<option>Spider</option>
<option>Goldfish</option>
</select>
<label for="test2">test2</label>
<select name="test2">
<option>Dog</option>
<option>Cat</option>
<option>Hamster</option>
<option>Parrot</option>
<option>Spider</option>
<option>Goldfish</option>
</select>
<input type="button" value="送出" onclick="processFormData()" />
</form>
<textarea id="output"></textarea>
<script type="text/javascript">
const processFormData = () => {
const form = document.forms["form"];
const test1 = form.elements.test1.value;
const test2 = form.elements.test2.value;
const output = `test1,${test1}\ntest2,${test2}`;
document.getElementById("output").innerHTML = output;
};
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment