• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getElementById not working in IE9 for bean

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am testing our application with IE9. We have code that works in IE7 but it's not working with IE9.

<jsp:useBean id="someForm" class="org.abc.desktop.form.someForm" scope="request" />

var elea = document.getElementById('someForm');

In IE9, getElementById is returning null.

I'm not a javascript expert, but I've been trying to research this all day. Does anyone have any ideas why this stopped working in IE9 or how to resolve?

Thanks for any help!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Showing us the server-side markup is not helpful. What is the HTML that is generated from this? That's all that JavaScript is going to see, and all you should be looking at to diagnose this.
 
Helene Prince
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The HTML that is generated for the bean is <form name="someForm" method="post" action="/UpdateSomeFormAction" onsubmit="return checkSubmit();">

I figured out a solution by using the method getElementsByName, but I would rather not have to do this (lots of places to change the code). Since IE9 changes the id to name, is there anyway to assign an id tag? I've played around with various options, but nothing seems to work.

<jsp:useBean id="someForm" class="org.abc.desktop.form.someForm" scope="request" />

I'm farily new to javascript (inheriting work from others), but I'm learning as I go. Thanks for your help!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Helene Prince wrote:Since IE9 changes the id to name, is there anyway to assign an id tag?


IE( does not change anything. It's the server-side markup that's generating the HTML that's sent to the browser. The browser has absolutely nothing to do with it.

So what markup is being used to generate the form tag? That's where the problem lies.

I'm farily new to javascript


This is not a JavaScript issue. It's just that the JavaScript is revealing a problem with the server-side markup, which is not generating the id attribute for the form tag.

P.S. The <jsp;useBean> markup is not what is generating the form tag -- what is?
 
Helene Prince
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If my understanding is correct, the form is created through the struts-config.xml file. I attempted to add an id tag there, but it didn't solve my problem. I guess I will stick with using the getElementsByName method since it's working, but at least I now have a much better understanding of the issue.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Helene Prince wrote:If my understanding is correct, the form is created through the struts-config.xml file.


Your understanding is not correct. The HTML form tag is likely generated by a struts tag in your page.

I attempted to add an id tag there, but it didn't solve my problem


Of course not. That has nothing to do with the issue.

I guess I will stick with using the getElementsByName method since it's working, but at least I now have a much better understanding of the issue.


Based on the above, I'd say you need to investigate this issue more because you do not have a good grasp of what's going on.

I suggest finding out where the form tag is being declared and actually fixing the problem rather than slapping a band-aid on it.
 
Helene Prince
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are correct that I don't understand everything about struts, but I do know that the form and action class is declared in the struts-config.xml file. The JSP references the action class.... so the struts tag in my page is
<html:form action="UpdateSomeAction" onsubmit="return checkSubmit();">

From the strut-config.xml file, the form and action is declared as:

<form-beans>
<form-bean name="someForm"
type="org.abc.desktop.form.someForm" />

<action path="/UpdateSomeAction"
type="org.abc.action.UpdateSomeAction"
name="someForm"
scope="request" />
</action>


Since the form name and class are declared in the struts-config.xml file, this is where I added the id tag, but it didn't solve my problem. I don't want to slap a band-aid on this to fix it, that's why I'm trying to research the problem. However, time is money and there is a limited supply of time and money sometimes.

I don't easily give up... so I'm still researching and trying to gain a better understanding as I go. Your suggestions have helped tremendously because it helped me to think/look in other directions, so I appreciate all your help!
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nowhere in your <html:form> tag do you give an id value to the HTML form!

You are confusing the HTML form with the bean that holds the form values. They are not the same!

At this point I'm going to move this to the Struts forum.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic