Fix attribute name in javascript function