aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Help needed with IE 6.0 submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Help needed with IE 6.0 submit " Watch "Help needed with IE 6.0 submit " New topic
Author

Help needed with IE 6.0 submit

Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Hi All,
I've got a JSP issue that I have been completely unable to resolve. The code I'm about to paste in does not work for IE6, works with FF, Chrome, Safari and Opera. Its a simple form submit. However when I try to run this in IE 6 I keep getting a 'Object does not support this property or method'. Up front I'm only posting the apparently relevant portions. I've highlighted the problem line with *************************************
Does anyone know how to get the Object to recognise or do the submit() method in IE 6

JSP:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Please UseCodeTags to make your code readable and preserve its formatting.

As the message is a JavaScript error, I've moved this to the appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Why not use a JavaScript library and get rid of all that browser compatibility stuff? I also noticed your <html:button> tag isn't properly closed--does the JSP even compile? Would the extension check method be better called something like "submitOnValidExtension"? There's no reason to set the form's action twice if you're only using doSubmit() as the IE6 submit function. And maybe the extension check itself could look like this:All that said, I don't know why the submit() function doesn't work for IE6--did you check to make sure that document.forms[0] is what you think it is when doSubmit is called?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(And consider formatting more consistently, and chopping off those trailing spaces.)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Even without the revamped valid extension method, I'd refactor a bunch of stuff to make things easier to understand, read, debug, and test:While it's not awesome (or tested), each method's purpose is more clearly defined: methods should do one thing, do it well, and do it completely.

(I also don't recall if calling a form's submit() function will also call its onsubmit handler--testing locally it didn't, so if you want prepPrice() to be called on submission you might want to check. You may just have spared us the extra code, too, in which case never mind :)
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Hey David,
Re-factored the code but still encountered the same issue in IE 6 the document object doesn't know the submit() method/function. Maybe I'll try posting this on the struts forum.

Chris
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Chris Ingram-Reid wrote:Re-factored the code but still encountered the same issue in IE 6 the document object doesn't know the submit() method/function.

Did you check to see if the object you're calling submit() on is the object you think it is like I asked?

The refactoring didn't change the code--just made it easier to understand.
Maybe I'll try posting this on the struts forum.

Why?
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Yes, I did. Please remember this code works in all other browser but IE6, I've never tired it in IE 7 +. so it is a valid Document object. Because html:form may not have all the properties of form for IE 6.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do you have a button named submit?

Eric
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
No there are no elements on the form named submit.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Chris Ingram-Reid wrote:Because html:form may not have all the properties of form for IE 6.

It's pretty easy to find out, no?!

And that it works in everything but IE6 is kind of the point: if the code specified for IE6 is actually executing, how did you verify that the object you're calling submit on in doSubmit() is the correct object?
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
And that it works in everything but IE6 is kind of the point: if the code specified for IE6 is actually executing, how did you verify that the object you're calling submit on in doSubmit() is the correct object?
----

Its always the same object even in the browser specific code, doSubmit() function. I use Microsoft Script Editor to step through the Javascript code when I load the page in IE 6. It is a Document Object, at least I think it is ...

Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
I posted the topic in the Struts forum and found a solution.


Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Messages: 370


[Post New]posted Today 9:50:49 AM private message [Email]
Quote [Up]
Try this. It'll fix the problem with IE

1. document.getElementById("myForm").submit();

----------------------------------------------------------------------
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Messages: 7


[Post New]posted Today 10:08:38 AM
Quote Edit [Up]
Ha, it worked. Thanks Raj, I've been trying to solve this for (2) two week
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
False alarm, I was using the wrong Browser.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please don't post browser issues in the Struts forum--it's not a Struts issue.
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
I apologize for doing so Dave, just looking for answers. The form won't submit in the most popular browser in the world, I'm still getting the same error message and I hate Microsoft.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

IE6 is not the most popular browser in the world, and hasn't been for some time:

http://www.w3schools.com/browsers/browsers_stats.asp
http://www.w3counter.com/globalstats.php

Note that verifying the object you thought you calling submit on was actually the form would have solved the problem--I wasn't just asking out of my own curiosity, I was asking the question that would have solved your problem.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Why in the world are you doing all of that funky logic to submit the form in the first place? All browsers will submit the form with document.forms[0].submit(); Code overkill there with strange object detection.




Eric
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Because unfortunately things are not always as they seem.

http://www.sixteensmallstones.org/ie-javascript-bugs-overriding-internet-explorers-documentgetelementbyid-to-be-w3c-compliant-exposes-an-additional-bug-in-getattributes/comment-page-1#comment-586
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure what that has to do with calling submit, though.
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Because with IE6 at the time of the submit() call I don't have a Form Object. This is why it doesn't recognize the submit, there's a bug in IE6.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Which is what I said originally. And why didn't you have a form object? Not because document.forms[0].submit() doesn't work.
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Exactly In IE only, the form will disappear.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Forms don't just disappear, even in the abomination that is IE6. Why don't you believe Eric?
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
I've tried his code, its not working with my form.

And in IE the form(s) have been known to disappear.

http://remysharp.com/2007/02/10/ie-7-breaks-getelementbyid/
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Which still doesn't seem to cover whatever issue it is you're having, but whatever.
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Object does not support this property or method. IE6 is not returning the correct element, every time.
Form disappearance doesn't cover the issue I'm having???

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Object does not support this property or method


Please copy the rendered page source and post it here. That error is telling me that your button is named submit.

Eric
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And the actual execution path of the JavaScript. Did you *try* not having all that weird submit malarky in there?
Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
I was able to resolve the problem by stripping the form to just the html:button, and the javascript code. Then adding each element one by one, eventually when I added an html:submit element the document.forms[0].submit() failed. I then added a property attribute to the html:submit element and it all works. FF, chrome, Safari, Opera and the venerable IE6.

Thanks for your help.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Chris Ingram-Reid wrote:I then added a property attribute to the html:submit element and it all works.


So when I posted this 8 hours ago:
Eric Pascarello wrote:Do you have a button named submit?

I was right.

If you would have posted the rendered code of the page from the start with all of the mark-up, you would have had this answered in a few hours, not days. Giving the correct info from the start would have made your life easier.

Eric

Chris Ingram-Reid
Greenhorn

Joined: Mar 29, 2010
Posts: 18
Its just too hard getting anything across to you guys, believe whatever you want.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

We do--Eric was right (I wasn't); the rendered HTML would have saved a lot of time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help needed with IE 6.0 submit