Ryan F. wrote in post #968899:
> I would like to create the id portion of a <td> tag using a string
> variable.  In my program i have a table that will have a varying number
> of columns determined by a variable in the parameter file, $gItems.

NO!  NO!  NO!  NEVER USE GLOBAL VARIABLES FOR THIS SORT OF THING!

OK, now that I've got your attention :) , please explain what you're 
trying to do with $gItems.  There will be a more appropriate place to 
put it than in a global variable; we just have to figure out what it is.

I
> would like to be able to loop through each row labeling each column
> based on its column number as shown below.  The problem is i do not know
> how to have the variable "item" read into the tag.  Any solution or
> other suggestion on how to solve this problem would be appreciated.

You can do this the same way you've done it on the next line.  ERb <%= 
%> can go anywhere.

Note, however, that Haml is generally a superior alternative to ERb, and 
in this case it provides an easier way to do this with its %tag[object] 
syntax.

>
> [code]
> <table>
>   <tr>
>     <%for item in 0..$gItems%>
>       <td id="col" + item.to_s >
>          <%= "col" + item.to_s %>
>       </td>
>     <%end%>
>   </tr>
> </table>
> [/code]

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to