A digital front for a local business
This code runs in Google App Script.
The files should be ran from within an App Script project.
Create an App Script project here
The App Script methods specific to Google spreadsheets are described here
append(object obj)
Extracts the data from obj and adds the data to the corresponding column in the sheet.
Append takes one parameter, an object (referred here as obj
)
The object should have the member variables below.
These should store the value of the input and select elements
Variable Name | Spreadheet Header |
---|---|
obj.hazard_source | Hazard Source |
obj.hazard_stage | Hazard Stage/ Occurrence |
obj.harmSrc | Energy/ Harm Source |
obj.duration | Duration Energy/ Harm Exposure |
obj.frequency | Frequency of Energy/ Harm Exposure |
obj.probability | Probability of Exposure |
obj.severity | Severity |
obj.transferExposure | Energy/ Harm Transfer Exposure |
obj.numTargets | # of Targets |
obj.fatalityFactor | Fatality Factor |
Example
function capture_harmData() {
var harmData = {};
harmData.hazard_source = dropDowns.hazard_source_dropdown.value;
harmData.hazard_stage = dropDowns.hazard_stage_dropdown.value;
harmData.harmSrc = dropDowns.harmSrc_dropdown.value;
harmData.duration = dropDowns.duration_dropdown.value;
harmData.frequency = dropDowns.frequency_dropdown.value;
harmData.probability = dropDowns.probability_dropdown.value;
harmData.severity = dropDowns.severity_dropdown.value;
harmData.transferExposure = txtInput.transferExposure_input.value;
harmData.numTargets = txtInput.numTargets_input.value;
harmData.fatalityFactor = txtInput.fatalityFactor_input.value;
//calling append function with harmData object
google.script.run.append(harmData);
}