Given this form declaration:

<form action="upload.php" method="post" enctype="multipart/form-data" onsubmit="return AIM.submit(this, {'onStart' : startCallback, 'onComplete' : completeCallback})">

How do I write the onsubmit dynamically? I have:

var f = document.createElement("form");
f.action = "upload.php";
f.method = "post";
f.enctype = "multipart/form-data";
f.onsubmit = function () { return AIM.submit(f, {'onStart' : startCallback, 'onComplete' : completeCallback}); };

But that doesn't work. What am I missing here?

Thanks,

JAS