This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Putting in a variable as an object name? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Putting in a variable as an object name?" Watch "Putting in a variable as an object name?" New topic

Putting in a variable as an object name?

Ivan Egan

Joined: Jan 09, 2003
Posts: 1
Trying to put in a number of radioboxes onto a page. I have a loop where 3 radioboxes are displayed each time, each time with the same name so only one can be chosen in each occasion of the loop.
Basically I want this,
<input type="radio" name="radiobox[$variable]"/>
if I used javascript or anything else, I would set the name = radiobox[i] where 'i' would change for each loop. But can't get the variable into the name field here.
Anyone able to help?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Evan,
You can either use the combinaison of <xsl:element> and <xsl:attribute> to achieve this. In <xsl:attribute>, you can use <xsl:value-of select="$variable"/> to output the value of your variable. Or use:
<input type="radio" name="radiobox[{$variable}]"/>
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Putting in a variable as an object name?