[thelist] IE JavaScript issues?

Lee kowalkowski lee.kowalkowski at googlemail.com
Fri Nov 17 03:13:16 CST 2006


On 16/11/06, Kristian Rink <kristian at zimmer428.net> wrote:
> function addNewField()
> {
>  var currentDate = new Date();
>  uploadForm = document.getElementById("fileUploadForm");
>  fileUploadField=document.createElement("input");
>  fileUploadField.setAttribute("id","upload"+currentDate.getTime());
>  fileUploadField.setAttribute("name","upload1"+currentDate.getTime());
>  fileUploadField.setAttribute("type","file");
>  fileUploadField.setAttribute("size","60");
>  fileUploadField.setAttribute("onchange","return addNewField();");
>  uploadForm.appendChild(fileUploadField);
>  return true;
> }

I did experience an IE issue when creating input elements.  Something
like document.createElement("input") creates a text input, and once
it's created, its type cannot be changed.

The workaround was something like document.createElement("<input
type='file'>"); - but I don't fancy that solution's chances
cross-browser.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/createelement.asp
says you can change the type as long as it is the first thing you do
after creating the element, but I'm not convinced.

-- 
Lee



More information about the thelist mailing list