From: Bala TS Date: 2011-09-26T13:31:20+09:00 Subject: Arrays and choose one Hai dude I will give one ideal try it your self // already you have array list in your controller file @first_list_box = [1,10,3,4] @second_list_box = [a,b,c,d] //Here you have two choice //one is combined two array.. @first_list_box.each do |first| //here 0 is index, All is display, if we select "All"then value is 0 //so before get length of the array index_num = @second_list_box.length index_num = index_num + 1 @second_list_box.insert(index_num,["#{first}",0) end // The result we be like this formet @second_list_box = [a,b,c,d,1,2,3,4] // so now you can use this way //Second is only selected value is insert //view or html.erb <%= select(:table_name, :field_num1, @first_list_box,{:selected => session[:second_array]}) %> //here session[:second_array] is like as temp variable so now i save selected value in session[:second_array] variable if i select 1 then the selected value is 1 that value i pass to session[:second_array] variable so now <% index_num = @second_list_box.length index_num = index_num + 1 @second_list_box.insert(index_num,["#{session[:second_array]}",0) %> <%= select(:table_name, :field_num2, @second_list_box) %> //now the result if you select @first_array_list_box => 1 then you can get @second_array_list_box values are like this [a,b,c,d,1] if you select @first_array_list_box => 2 then you can get @second_array_list_box values are like this [a,b,c,d,2] if you select @first_array_list_box => 1 first time and second time 2 then you can get @second_array_list_box values are like this [a,b,c,d,1,2] this like is used for array handling http://corelib.rubyonrails.org/classes/Array.html#M000431 bye :) -- Posted via http://www.ruby-forum.com/.