Hi,
Can anyone please help me. What I want to do here is to print the label
and text field of this part of the table 5 times. The output I expected
to get is this:
TEXT NUMBER 0   (this is where the TEXT_FIELD will appear)
TEXT NUMBER 1   (this is where the TEXT_FIELD will appear)
            .
            .
            .
TEXT NUMBER 5   (this is where the TEXT_FIELD will appear)
This are the codes I used:
<% for num in (0..4) %>
    <tr>
        <td style="width: 374px;"><label>TEXT NUMBER
"#{num}"
</label></td>
        <td style="width: 219px;"><input name=""
 type="integer"></td>
      </tr>
<% end %>
Thanks,
fries88
-- 
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Hi,
 Can anyone please help me. What I need to do here is to print the label
 and text field of this part of the table 5 times. The output I expected
 to get is this:
 TEXT NUMBER 0   (this is where the TEXT_FIELD will appear)
 TEXT NUMBER 1   (this is where the TEXT_FIELD will appear)
             .
             .
             .
 TEXT NUMBER 5   (this is where the TEXT_FIELD will appear)
 Instead, what I get is:
 TEXT NUMBER #{num}   (this is where the TEXT_FIELD will appear)
 TEXT NUMBER #{num}   (this is where the TEXT_FIELD will appear)
             .
             .
             .
 TEXT NUMBER #{num}   (this is where the TEXT_FIELD will appear)
 This are the codes I used:
 <% for num in (0..4) %>
     <tr>
         <td style="width: 374px;"><label>TEXT NUMBER
"#{num}"
 </label></td>
         <td style="width: 219px;"><input name=""
  type="integer"></td>
       </tr>
 <% end %>
 Thanks,
 fries88
-- 
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Can you loop in Ruby? Also, you need to use erb to execute the code. I bet you don''t understand what that means. </annoyingandpro> On Jan 10, 10:12 am, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > Can anyone please help me. What I need to do here is to print the label > and text field of this part of the table 5 times. The output I expected > to get is this: > > TEXT NUMBER 0 (this is where the TEXT_FIELD will appear) > TEXT NUMBER 1 (this is where the TEXT_FIELD will appear) > . > . > . > TEXT NUMBER 5 (this is where the TEXT_FIELD will appear) > > Instead, what I get is: > > TEXT NUMBER #{num} (this is where the TEXT_FIELD will appear) > TEXT NUMBER #{num} (this is where the TEXT_FIELD will appear) > . > . > . > TEXT NUMBER #{num} (this is where the TEXT_FIELD will appear) > > This are the codes I used: > > <% for num in (0..4) %> > <tr> > <td style="width: 374px;"><label>TEXT NUMBER "#{num}" > </label></td> > <td style="width: 219px;"><input name="" > type="integer"></td> > </tr> > <% end %> > > Thanks, > fries88 > -- > Posted viahttp://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
August Lilleaas wrote:> Can you loop in Ruby? > > Also, you need to use erb to execute the code. I bet you don''t > understand what that means. > > </annoyingandpro> > > On Jan 10, 10:12?am, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi, Yup I don''t understand what your talking about. Can anyone please explain? Thanks, user splash (I am a beginner) -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 10 Jan 2008, at 09:51, user splash wrote:> > August Lilleaas wrote: >> Can you loop in Ruby? >> >> Also, you need to use erb to execute the code. I bet you don''t >> understand what that means. >> >> </annoyingandpro> >> >> On Jan 10, 10:12?am, user splash <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > > > Hi, > > Yup I don''t understand what your talking about. Can anyone please > explain? > > Thanks, > user splash (I am a beginner) >It''s rather confusing if you post with 2 different identities (seems odd that both you and fries88 have exactly the same question). Anyway, go back to where you first read about rhtml templates and read about the difference between <% and <%#{} only works when ruby evaluates a string, which isn''t what is happening here. Fred> -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
andy.keep-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-10  14:19 UTC
Re: Need help for loop
Hi um fries 88,
I think the only problem is the TEXT NUMBER "#{num}" line.  Where
you''ve got #{num} here isn''t being interpreted by ruby because
you''ve
not wrapped it with an <% %> to tell ruby to take a look at it.
Really you don''t need the "#{num}" all you should need to do
is TEXT
NUMBER <%= num %>.
Just fyi, using a for loop as you are is a little slower then using
either the times or upto... as far as why it is slower I''m not really
sure, but times and upto are definitely the "ruby way"...
e.g.
<% 5.times do |num| %>
    ... TEXT NUMBER <%= num %> ...
<% end %>
or
<% 0.upto 4 do |num| %>
    ... TEXT NUMBER <%= num %> ...
<% end %>
The upto form has the added benefit that you can start from an
arbitrary place (like 1 if you wanted to be 1 based instead of zero
based) and go through what your ended number should be.
<% 1.upto 5 do |num| %>
   ...
<% end %>
Hope that helps.
-andy:)
On Jan 10, 3:30 am, fries 88
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> Hi,
> Can anyone please help me. What I want to do here is to print the label
> and text field of this part of the table 5 times. The output I expected
> to get is this:
>
> TEXT NUMBER 0   (this is where the TEXT_FIELD will appear)
> TEXT NUMBER 1   (this is where the TEXT_FIELD will appear)
>             .
>             .
>             .
> TEXT NUMBER 5   (this is where the TEXT_FIELD will appear)
>
> This are the codes I used:
>
> <% for num in (0..4) %>
>     <tr>
>         <td style="width: 374px;"><label>TEXT NUMBER
"#{num}"
> </label></td>
>         <td style="width: 219px;"><input
name=""
>  type="integer"></td>
>       </tr>
> <% end %>
>
> Thanks,
> fries88
> --
> Posted viahttp://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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---