File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes document.forms[0].submit(); throws Invalid Argument in IE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "document.forms[0].submit(); throws Invalid Argument in IE" Watch "document.forms[0].submit(); throws Invalid Argument in IE" New topic
Author

document.forms[0].submit(); throws Invalid Argument in IE

Anirban Chowdhury
Ranch Hand

Joined: Aug 05, 2008
Posts: 36
Hi All,
I have a peculiar problem. I am developing a Struts 2.2 website. Now in one of the jsps, I use a function which inturn submits to another action.
Now, the problem is if, I call this function when it is present in .js file, it throws me an error "Invalid Argument".
However, if I copy-paste the same method in the jsp, then it works fine.


This is the method. The 0 is also alerted out, when I put the function definitiion in both the js file as well the jsp. However, the page doesn't get submitted from the .js file.
Am I missing something here?

Thanks a lot in advance!
Anirban


To living life on the edge! I blog my experiences @ http://anirbanchowdhury.wordpress.com.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do you have a form element named submit? If you do, rename it.

Eric
Anirban Chowdhury
Ranch Hand

Joined: Aug 05, 2008
Posts: 36
Hi Eric,
Thanks for your reply. I did have and I changed both the id and the name of the element. I checked the source as well after the page was rendered.Nothing with "submit". but sill the problem persists. This has a very easy workaround, but I hate duplicate code all over the jsps..

Thanks & Warm Regards
Anirban.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what does your form look like?

Eric
Anirban Chowdhury
Ranch Hand

Joined: Aug 05, 2008
Posts: 36
This is the button :


Also pasted below the source code, if you need it.


Thanks once again.

Anirban
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Form works fine for me, looks like you lost some of the code in it from not checking the "Disable HTML in this message" checkbox.

Eric
Anirban Chowdhury
Ranch Hand

Joined: Aug 05, 2008
Posts: 36
Hi Eric,
Sorry my mistake!! I forgot to mention that it doesn't work if I put the function confirmDeleteEntity() into a js file. In this case, it works as the function is incuded. And no, the form has been completely rendered here. Thanks once again for your review Eric. I so , so want to get to the end of this..

Anirban.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: document.forms[0].submit(); throws Invalid Argument in IE