var parent; function doTests(p){ parent = p; createTests(newTest); } function newTest(text, options){ var testbox = document.createElement("div"); testbox.className = "testbox"; var format = (typeof options !== "undefined" && options.format) || "auto"; testbox.innerHTML = '\ Format: ' + format + '
\ Input: ' + text + '
\
\ '; try{ JsBarcode(testbox.querySelector('.barcode'), text, options); } catch(e){ testbox.className = "errorbox"; testbox.onclick = function(){ throw e; } } parent.appendChild(testbox); }