Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
shehackedyou
Aug 14, 2004

it is never too late to give up your prejudices
Hello, I am having an issue looping through several groups of radio buttons.

So my goal is to loop through and list several groups of shipping options for various products. First I loop through the number of items which need to be shipped alone, then I loop through the shipping rates. What I want is each group to be able to have 1 selection and pass along the params for use in the controller. I need the ability to iterate or count the ss_ship_info so that each name/value will be different params. I have tried both 'ss_ship_info[@counter]' and 'ss_ship_info'[@counter] (this one has really unexpected results, if I have 3 items. The first two act like a single group but the third seems to be an individual group.) Does anyone know a solution for my problem or at the very least could point me in the direction of a guide relating to the subject?

code:
<% @sscount.times do %>  #First Loop 
   <% for rate in @ups_ss_rates[@counter] %> # Second Loop 
      <label> 
         <%= radio_button_tag('ss_ship_info[]'[@counter], rate[0]) %> 
         <%= rate[0] %> - <span class="money"><b><%= sub_number_to_currency((rate[1])) %></b></span> 
      </label> 
    <% end %> 
   <% @counter += 1 %> 
<% end %> 
Edit: I think I figured it out by understanding how to put variables inside of a string.

Edit2: 'ss_ship_info_#{@counter}' doesn't seem to work either =\

Edit3: This bit of code did the trick, it allows me to loop through loops of radio buttons and iterating each group so they are separate parameters. Maybe this will help someone out some day.

code:
<%= radio_button_tag("ss_ship_info_" + @counter.to_s, rate[0]) %>

shehackedyou fucked around with this message at 08:35 on Jan 28, 2011

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply