I’m using a basic SELECT element, and tracking it’s onChange events with a Snapshot. However, I never get the index returned, just a -1.
The Heap docs provide this valuable tidbit of info… (and suspect this is the culprit).
var selector = 'li.h-full' // Replace this CSS! Selector must target all of the elements in the list
But if my HTML code is simply…
<select name=”fieldA” class=”selectStyles”>
<option value=”-1”>- Select -</option>
<option value=”0”>Apples</option>
<option value=”1”>Oranges</option>
<option value=”2”>Grapes</option>
</select>
What selector is Heap hoping for? Currently, my snapshot contains this code…
(function() {
var selector = 'option'
var selected_element = event.target.closest(selector)
var all_elements = document.querySelectorAll(selector)
return Array.prototype.indexOf.call(all_elements, selected_element);
})()
Thanks for any assistance!!!
Best answer by dlad
View original