[Javascript] Appending an input to a form in Internet Explorer
Robert Crawford
robertcrawford at peoplepc.com
Wed Mar 23 15:46:15 CST 2005
German Sibay said the following on 3/23/2005 3:19 PM:
> Hello, I´m trying to append an input field to a form.. seems easy.
>
> It works on Mozilla but it does not in IExplorer.
>
> The last line (the append) throws an error “invalid argument”
>
> Any clue?
>
> function addInputField (form, fieldType, fieldName, fieldValue) {
>
> var input = document.createElement("INPUT");
>
> input.setAttribute('type', fieldType);
>
> input.setAttribute('name', fieldName);
>
> input.setAttribute('value', fieldValue);
>
> form.appendChild(input);
>
> }
>
> Germán Sibay
>
German,
Have tried this way;
function addInputField (form, fieldType, fieldName, fieldValue) {
var input = document.createElement("INPUT");
form.appendChild(input);
input.setAttribute('type', fieldType);
input.setAttribute('name', fieldName);
input.setAttribute('value', fieldValue);
}
This gives it the same order as your function output.
Just a thought ....
Robert
More information about the Javascript
mailing list