views:

33

answers:

1

Hi,

how come that when I attach onchange by attribute and call it

onchange="validateDate(FPR_CURR_FROM);"

it works, but when I use a ASP .NET validator, and my attached function is called like :

function anonymous() {
   ValidatorOnChange(event);  
   validateDate(FPR_CURR_FROM);
}

I get error: FPR_CURR_FROM is undefined.

First off: I know that using FPR_CURR_FROM to access element is BAD, and I should use getElementByID etc... And I will change it eventually. But as I bumped into that code, I'm curious what caused it - propably visibility of variables I guess.

A: 

I think it's a scoping issue, yes, it would take seeing more code and how anonymous is called, but that is what it looks like to me from what I see... One way around that is to attach the FPR_CURR_FROM variable to the window object, and access it via window.FPR_CURR_FROM...

Brian