Fix undefined variable JavaScript error.