Solved

JavaScript and <html:text> in FireFox

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

910 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

19 Experts available now in Live!

Get 1:1 Help Now