recursive function call and innerHTML call from javascript