Hi,
Try this simple solution that is using onload event on body tag...
<html>
<head>
<script>
var counter = 0;
function AddFileUpload()
{
var div = document.createElement('DIV');
div.innerHTML = '<input id="file' + counter + '" name = "file' + counter + '" type="file" /><input id="Button' + counter + '" type="button" value="Remove" onclick = "RemoveFileUpload(this)" />';
document.getElementById("FileUploadContainer").appendChild(div);
counter++;
}
function RemoveFileUpload(obj)
{
return false;
}
</script>
</head>
<body onload="AddFileUpload();">
<div id="FileUploadContainer"></div>
<input type="button" value="Add" onclick="AddFileUpload();return false;">
</body>
</html></html>
If you use jquery you can use .ready() event to call this whem dom is ready...
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
var counter = 0;
function AddFileUpload()
{
var div = document.createElement('DIV');
div.innerHTML = '<input id="file' + counter + '" name = "file' + counter + '" type="file" /><input id="Button' + counter + '" type="button" value="Remove" onclick = "RemoveFileUpload(this)" />';
document.getElementById("FileUploadContainer").appendChild(div);
counter++;
}
function RemoveFileUpload(obj)
{
return false;
}
$(document).ready(function () {
AddFileUpload();
});
</script>
</head>
<body>
<div id="FileUploadContainer"></div>
<input type="button" value="Add" onclick="AddFileUpload();return false;">
</body>
</html></html>