Solved

JavaScript and <html:text> in FireFox

Posted on 2006-11-13
2
1,083 Views
Last Modified: 2013-12-16
Please be gentle - I'm not a developer, just trying to fix something the original developer wrote.

I have a Java application that is displaying a set data entry fields using <html:text>; each field has JavaScript associated with it for some automatic calculations and to automatically changing the text color under certain conditions.

However, the JavaScript does not run in FireFox, while it does run in IE.  Here is the error received:
      document.getElementById(propPrefix + "cActual") has no properties

After some research, I believe the reason is because the <html:text> which defines the field does not have an ID for the JavaScript to reference (I found somewhere that IE will reference a field by Name, but FF requires the ID).

When I add an ID tag to the <html:text> field I get this error when the screen attempts to display:
      Attribute id invalid for tag text according to TLD

So, is there some way to add an ID to the <html:text> field, or some other resolution to my problem?  Thanks for any help you can provide.  Copies of the relevant field and JavaScript lines are just below.

      <html:text property="<%= propertyPrefix + "cActual" %>" size="6" maxlength="10"
        onblur="<%= onBlur + " setAsFoundAsLeftFromActual(" + jobFuncReadingIndex + ");" %>"
        onchange="<%= "setReadingDataChangedState('" + jobFuncReadingIndex + "', 'cActual');
        calcDevFromAct(" + jobFuncReadingIndex + ");
        form.elements['" + propertyPrefix + "cDeviation'].value = formatNumber(form.elements['" + propertyPrefix +  
        "cDeviation'].value, '0.' + getDecimalPattern(form.elements['" + propertyPrefix + "nDecimals'].value));
        checkToleranceActual(" + jobFuncReadingIndex + ");" %>"/>


           if (document.getElementById("cActual").value != "" && isNaN(document.getElementById("cActual").value) == false) {
         document.getElementById("cActual").value =
         formatNumber(document.getElementById("cActual").value, "0." + getDecimalPattern(nDecimals));
         
         document.getElementById("cActual_dirty").value = true;
     } // if (document.getElementById("cActual").value != "" && ...)
0
Comment
Question by:ajraven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
netmunky earned 500 total points
ID: 17933034
what is the value of propertyPrefix / propPrefix?

i don't see any name= or id= in your code. javascript has 2 similar functions, getElementById and getElementByName that search based on the id and name, respectively. if an element does not have an id or name, the searches will not work.

try changing:
<html:text property="<%= propertyPrefix + "cActual" %>"
to:
<html:text property="<%= propertyPrefix + "cActual" %>" id="<%=propertyPrefix + "cActual" %>"
0
 

Author Comment

by:ajraven
ID: 17951107
Thanks for the response, netmunky.
I suspected the problem was a lack of an "id" tag.
That definitely set me in the right direction.

However, for those who may have a similar problem in the future:
I forgot to mention that we're using the Struts development environment; in Struts, the tag "id" is not supported for html:text.
Turns out the Struts version is "StyleId".
Changing the line to read:
<html:text property="<%= propertyPrefix + "cActual" %>" StyleId="<%=propertyPrefix + "cActual" %>" />
worked.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question