Solved

JavaScript and <html:text> in FireFox

Posted on 2006-11-13
2
1,073 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now