Skip to content

Instantly share code, notes, and snippets.

@tobychung
Last active September 6, 2021 13:18
Show Gist options
  • Save tobychung/096fbdb6a6be7b6ac511c17b3dbba67b to your computer and use it in GitHub Desktop.
Save tobychung/096fbdb6a6be7b6ac511c17b3dbba67b to your computer and use it in GitHub Desktop.
var result = [];
const fields = [
{
type: "radio",
label: "1. 同意",
name: "128514X57X1626",
value: true,
},
{
type: "text",
label: "2. 工號",
name: "128514X57X1627",
value: "123456",
},
{
type: "radio",
label: "3. agreement",
name: "128514X57X1630",
value: true,
},
{
type: "text",
label: "4. 溫度",
name: "128514X57X1629",
value: "36.4",
},
{
type: "radio",
label: "5.1. 哪些症狀",
name: "128514X57X1629",
value: true,
},
{
type: "radio",
label: "5.2. 接受治療?",
name: "128514X57X1628",
value: true,
},
];
// 填寫表單
fields.forEach(({ type, name, value }) => {
const target = document.getElementsByName(name)[0];
if (type === "radio") {
target.checked = true;
}
if (type === "text") {
target.value = value;
}
});
// 勾選症狀 (無症狀)
const event = new MouseEvent("click");
const noSymptoms = document
.getElementById("javatbd128514X57X1631SQ07")
.getElementsByTagName("LABEL")[0];
noSymptoms.dispatchEvent(event);
// 送出表單
var submitButton = document.getElementById("ls-button-submit");
submitButton.dispatchEvent(event);
// 呼叫 Completion 以完成
completion(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment