var qr_type = document.getElementById('qr_type');
Just a comment, be aware that in Internet Explorer, names and IDs are global variables and thus you should NEVER use a global variable or function name which is the same as an HTML element name or ID.
Here your variables are local, not global scope, but even so it is perhaps unwise or confusing to assign the same name.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.