Solved

JavaScript and <html:text> in FireFox

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
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!
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

831 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