Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

styleID attribute

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I know the purpose of styleID attribute(Ex:in html:text). It's basically to give the element an ID attribute since the name attribute is overloaded.

But I am having problem in assigning id attribute for a element which has indexed/nested property.

<html:text indexed="true" name="riskResults" property="riskFromDate" size="10" maxlength="10" styleClass="AdmTextBox" />

I have to specify name attribute because "rishResults" is a innerbean for the outerone, like this

public class LymeSupplementForm extends ValidatorActionForm {
private String firstName;
private List riskList = new ArrayList()
public RiskResults getRiskResults(int index)
{
while(index >= riskList.size()){
riskList.add(new RiskResults());
}
return (RiskResults)riskList.get(index);
}

public void setRiskResults(int index,RiskResults risk)
{
riskList.set(index,risk);
}
}

in my javascript, I do something like this
var inDate = trim(document.getElementById('riskResults['+ 0+ '].riskFromDate').value);

this is where I get the problem. It works fine in IE but not in Mozilla. IE automatically treates the name attribute as ID but for Mozilla, I had to explicilty specify ID attribute.
I tried adding styleID attribute but still no,luck

Can someone please help me?
[ March 27, 2007: Message edited by: Vani D Bandargal ]
 
Sheriff
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask questions on the Struts tags in the Struts forum. This post has been moved there for you.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The indexed attribute of the <html:text> tag causes the name attribute of the rendered HTML page to be indexed. However, it does nothing with the styleId attribute except pass it through as-is to create the id attribute in the rendered HTML. If you want an indexed value for the id, you will have to build it yourself using a scriptlet.

There is another way to do it, though. I'd suggest using the JavaScript getElementsByName function. This function always returns an array, even if there is only one element with the specified name. Something like the following would work:


[ March 27, 2007: Message edited by: Merrill Higginson ]
 
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic