var input;
try {
input = document.createElement('<input type="text" name="searchfield[]" />');
}
catch (error) {
input = document.createElement("input");
input.setAttibute("type", "text");
input.setAttibute("name", "searchfield[]");
}
или так:
function parseHTML(htmlCode) {
var tmp = document.createElement("div");
tmp.innerHTML = htmlCode;
return tmp.firstChild;
}
var input = parseHTML('<input type="text" name="searchfield[]" />');