Set the input tag type and name with jQuery's attr() method to avoid any string escaping issue

Factorise some code too
Merge branch 'features/support-preselection-and-caption-on-options'