<HTML>
<Head>
<Title> </title>
<Script language = "JavaScript" type = "text/JavaScript">
Function createelement (tagname, type)
{
VaR element = NULL;
Try
{
Element = Document. createelement ('<' + tagname + 'name = "'+ name +'"/> ');
Element. type = type;
Element. value = value;
}
Catch (E)
{
}
If (! Element)
{
Element = Document. createelement (tagname );
Element. setattribute ("type", type );
}
Return element;
}
Function add ()
{
VaR input1 = createelement ("input", "file ");
VaR BR = Document. createelement ("<br/> ");
VaR files = Document. getelementbyid ("Files ");
Files. appendchild (BR );
Files. appendchild (input1 );
}
</SCRIPT>
</Head>
<Body>
<Input type = "button" value = "add" onclick = "add ();"/>
<Div id = "Files">
<Input type = "file"/>
</Div>
</Body>
</Html>
The code snippet for dynamically creating any input element is as follows: function createelement (tagname, name, type, value)
{
VaR element = NULL;
Try
{
Element = Document. createelement ('<' + tagname + 'name = "'+ name +'"/> ');
Element. type = type;
Element. value = value;
}
Catch (E)
{
}
If (! Element)
{
Element = Document. createelement (tagname );
Element. setattribute ("type", type );
Element. setattribute ("name", name );
Element. setattribute ("value", value );
}
Return element;
}