complete add and javascript code