Solved

JavaScript and <html:text> in FireFox

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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
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 is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

630 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