wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Object doesn't support this property or method 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 "Object doesn Watch "Object doesn New topic
Author

Object doesn't support this property or method

Smita Ahuja
Greenhorn

Joined: Sep 23, 2013
Posts: 28
Hi,

I Developed a struts1.2 application , In one of the jsp function called on button(<input TYPE="button" name="action" value="Submit" ALT="BTN_SUBMIT" onclick='javascript:onSubmit("<bean:write name="dResult" property="completeFilePath"/>")'>) click I am calling below code :
function onSubmit(filename){
document.forms[0].action = "/CordellSearchProject/SubmitIt.do?filename=" + filename;
document.forms[0].name = "searchForm";
document.forms[0].setAttribute("method", "post");
document.forms[0].submit();
}
Its working fine in every browser(IE 9, Firefox,Chrome), but in IE 8 its throwing an error "Object doesn't support this property or method"

Please help, any kind of help would be appreciated.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

So this appears to be a question about some Javascript code and not about JSP, particularly. Since we have a forum about Javascript I'm going to move this post over there.

It would also help if you mentioned which line of code caused the error.
Smita Ahuja
Greenhorn

Joined: Sep 23, 2013
Posts: 28
Thanks Paul,

error is coming on document.forms[0].action
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Perhaps you should use a less archaic and obsolete means to reference the form element? I suggest giving it an id and using document.getElementById() (or use jQuery to do all this much more easily).


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Smita Ahuja
Greenhorn

Joined: Sep 23, 2013
Posts: 28
Hi Bear,

Thanks for your reply...
but how to make form id in <html:form method='post' action="/searchAction.do">
when I add it as <html:form id="searchForm" name="searchForm" method='post' action="/searchAction.do">

Its giving below error:

Attribute id invalid for tag form according to TLD
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

<mini-rant>Frameworks that replace HTML elements with their own tags and don't use the same attribute names.</mini-rant>

You'll need to refer to the documentation for the tag for the sub-standard framework that you are using to find out how to assign the element an id.
Smita Ahuja
Greenhorn

Joined: Sep 23, 2013
Posts: 28
I am using struts 1.3
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Do you not have access to the documentation?
Smita Ahuja
Greenhorn

Joined: Sep 23, 2013
Posts: 28
we can add <html:form styleId="formId" method='post' action="/searchAction.do">
but on document.getElementById[formId].action, its giving error as null on formId....
I think its because of formName is not mentioned in htm:form tag....
Do anybody know how to add formname in html:form tags


Please help, I am badly stucked.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

You don't neen a name. All you need is an id. I've already told you how to do it. Assign an id to the form element and use document.getElementById() to get a reference to the form element. Or use jQuery.

Worrying about names and such is a waste of your time.
 
 
subject: Object doesn't support this property or method
 
Similar Threads
problem setting form Action name Dynamically on button click
How to link different buttons to different action methods
object doesn't support this property or method
Help needed with IE 6.0 submit
Object doesn't support this property or method