use setAttribute to set onclick attr
combine add dialog; code style
new feature: add with option mostly realized
new feature: add with option mostly realized