Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Last active November 27, 2018 18:18
Show Gist options
  • Save rjcorwin/b54356fdeb075f49293212eb370975a5 to your computer and use it in GitHub Desktop.
Save rjcorwin/b54356fdeb075f49293212eb370975a5 to your computer and use it in GitHub Desktop.
if (inputs.location.value[3]) {
let selectedLocationNode = Loc
.flatten(inputs.location.locationList)
.find(node => node.id === inputs.location.value[3])
if (selectedLocationNode.label === 'Other') {
// Do something.
}
}
if (inputs.location.value[3]) {
let selectedLocationNode = inputs.locationList
.locations[inputs.location.value[0]]
.children[inputs.location.value[1]]
.children[inputs.location.value[2]]
.children[inputs.location.value[3]]
if (selectedLocationNode.label === 'Other') {
// Do something.
}
}
@lachko
Copy link

lachko commented Nov 27, 2018

I've inserted this as a final version:

if (typeof inputs.location.locationList != 'undefined'
&& inputs.location.value[3].value != 'undefined'
&& getValue('other_county') == '' && getValue('other_district') == ''
&& getValue('other_location') == '' && getValue('other_school') == '') {
let selectedLocationNode = inputs.location.locationList
.locations[inputs.location.value[0].value]
.children[inputs.location.value[1].value]
.children[inputs.location.value[2].value]
.children[inputs.location.value[3].value]

if (selectedLocationNode.label === 'Other, please specify') {
inputShow('other_location')
inputShow('other_school')
} else {

inputHide('other_location') 
inputHide('other_school') 

}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment