can someone please help me out? I'm trying to create an input dynamically with this function, but the "form" attribute is not being set.
function addInput(parentID,inputNAME) {
var padre = document.getElementById(parentID);
var container = document.createElement("input");
container.type = "text";
container.name = inputNAME;
container.value = "";
container.form = 'extra';
var enter = document.createElement("br");
padre.appendChild(container);
padre.appendChild(enter);
}
I've also tried with this:
container.formName = 'extra';
container['form'] = 'extra';
container.attributes['form'] = 'extra';
container.createAttribute('form','extra')
EDIT:
Answer:
container.setAttribute("Form",'extra');
setAttributeis setting a custom attribute on the element. I think you should describe what the end goal is.setAttribute()works in FF but it has no effect as this is unrelated to the propertyformwhich, as the answer says, is implicitly set to the form you append the field to.formattribute is new in HTML5, it allows you to associate a form field with an arbitrary form.