• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object doesn't support this property or method

 
Smita Ahuja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,

error is coming on document.forms[0].action
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Smita Ahuja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using struts 1.3
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you not have access to the documentation?
 
Smita Ahuja
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic