Dear Javascript Gurus out There…

I have a bit of code that is using the excellent free XUpload progress bar. I’ve modified it a bit for my current project, and am having some performance issues due to some javascript I added.

What happens is the main <FORM> tag has an onSubmit() action of calling a StartUpload() function. I’ve added code to the start of the fuction to check to see if a delete file button has been pressed, and if it is the button and not the ‘upload’ button, it simply returns and doesn’t open the file transfer dialog.

My code looks like this (added code in green):

function StartUpload()
// first check if it’s a ‘delete_xxx’ button being hit, and return
for (var i=0;i<document.F1.length;i++)
current = document.F1.elements[i];
if(current.type==’submit’ &&

// … rest of function here…

It works, and it’s really slow, because I presume it goes through every single (HTML? or just form?) element on the page. What I really need is to find out what the current button that was pressed is. I know the name will be “delete_XX” where XX is a number from 01 to 05.

Can anyone help me out?

Update: I fixed this by digging a bit deeper into the code. In there there is a counter for the number of file browse dialogs that are not set to an empty string, so simply checking for if the counter is greater than 0 or not worked dandy. There is still an edge case where a large upload under mozilla gives the “Script is causing your computer to perform slowly” message, but I think that’s somewhere in my code.