For this block of code:
if(!skipit)
{
var update_argument='';
if (document.formname.fieldname)
{
update_argument=document.formname.fieldname[document.formname.fieldname.selectedIndex].value;
}
window.setTimeout('updatepcols(update_argument)',250);
return false;
}
I was getting an error in my setTimeout call that “update_argument” was undefined. When I changed the line where I assign it the null string value from “var ” to “window.”, the error was gone and the code worked. I would guess that there’s a scope issue here, but I don’t follow it. Why would update_argument be undefined in this case, but putting it in the window object lets me use it? (updatepcols is a function that updates pricing columns.)
Try this instead. Using a closure in this fashion preserves the reference to
update_argumentI have a funny feeling the script you passed as text, when evaluated, executes in the global scope, i.e. outside the local scope in which
update_argumentis declared.