I've still been stumped by this but found this link in the forum in case anyone might have an idea on a solution:
Is the problem that km variables are "read-only" to javascript? I am trying to assign a variable from document.kmvar to a js variable in a function argument, and it looks like it's not even read. But kmvars can be read outside of an argument in a function? Sorry if it's a js noob question, I'm confused!