Forum: Ruby on Rails Search Results into new table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7af028825f6c0f24554c69b2c93729a0?d=identicon&s=25 Nick Hoyle (hoylen)
on 2009-03-18 21:06
I have a search form on my rails site. once the a user has entered a
query it displays the results in a table with an extra field button so
it can be added to there own portfolio called add to my stocks.

How do i get the data for the stock they want to add and put this into a
new table called mystocks.

Is using a form submit button the right choice?

Any examples much appreciated

Regards

Nick
Ba40fb9469683d3a161fb5e8ae370a6f?d=identicon&s=25 Nat (Guest)
on 2009-03-18 23:11
(Received via mailing list)
#Search stock view
<%form_tag(:action=>:search_stock) do%>
<%=submit_tag('Search")%>
<%end%>


#Search Stock Controller
def search_stock
 @stocks = Stock.find_by_something()
 render action=>:result_page
end


#Result Page
<%form_tag(:action=>:add_to_my_stocks) do %>
  <%@stocks.each do |stock|%>
     #Create set of checkbox and use stock_id as id
 <%end%>
<%end%>

On Mar 18, 1:06 pm, Nick Hoyle <rails-mailing-l...@andreas-s.net>
7af028825f6c0f24554c69b2c93729a0?d=identicon&s=25 Nick Hoyle (hoylen)
on 2009-03-18 23:22
Nat wrote:
> #Search stock view
> <%form_tag(:action=>:search_stock) do%>
> <%=submit_tag('Search")%>
> <%end%>
>
>
> #Search Stock Controller
> def search_stock
>  @stocks = Stock.find_by_something()
>  render action=>:result_page
> end
>
>
> #Result Page
> <%form_tag(:action=>:add_to_my_stocks) do %>
>   <%@stocks.each do |stock|%>
>      #Create set of checkbox and use stock_id as id
>  <%end%>
> <%end%>
>
> On Mar 18, 1:06�pm, Nick Hoyle <rails-mailing-l...@andreas-s.net>

Thanks for quick response

How exactly do you do a checkbox with an id?

<%= form.check_box :stock_id %>?
7af028825f6c0f24554c69b2c93729a0?d=identicon&s=25 Nick Hoyle (hoylen)
on 2009-03-18 23:29
>
> Thanks for quick response
>
> How exactly do you do a checkbox with an id?
>
> <%= form.check_box :stock_id %>?

ignore me ive sorted that, was looking at a wrong example
D2beadad6e279067d5f9e272e75910e0?d=identicon&s=25 khim sreang (Guest)
on 2009-03-19 02:46
(Received via mailing list)
>
> Hi all now i am doing with advanced search  by using checkboxs and redio
> button for each items
>
      for example :


<% form_for *:tblpss_description_record*, *@tblpss_description_record*,
*
:url*=>{ *:action*=>'view_detail_job_setup' }, *:html*=>{ *:id*=>
'frm_view_setup', *:name*=>'frm_view_setup', *:method* => *:get*}
*do*|f|%>


<input type="checkbox" name="elementprovince" value="ALL"
id="optPROVINCE"
onclick="changeBoxesProvince(1)">ALL<br>

<input type="checkbox" name="elementprovince" value="PHNOM PENH" id=
"optPROVINCE">PHNOM PENH<br>

<input type="checkbox" name="elementprovince" value="BANTEAY MEANCHEY"
id=
"optPROVINCE">BANTEAY MEANCHEY<br>

<input type="checkbox" name="elementprovince" value="BATTAMBANG" id=
"optPROVINCE">BATTAMBANG<br>

<input type="checkbox" name="elementprovince" value="KAMPONG CHAM" id=
"optPROVINCE">KAMPONG CHAM<br>

<input type="checkbox" name="elementprovince" value="KAMPONG CHHNANG"
id=
"optPROVINCE">KAMPONG CHHNANG<br>

<input type="checkbox" name="elementprovince" value="KAMPONG SPEU" id=
"optPROVINCE">KAMPONG SPEU<br>

<input type="checkbox" name="elementprovince" value="KAMPONG THOM" id=
"optPROVINCE">KAMPONG THOM<br>

<input type="checkbox" name="elementprovince" value="KAMPOT" id=
"optPROVINCE">KAMPOT<br>

<input type="checkbox" name="elementprovince" value="KANDAL" id=
"optPROVINCE">KANDAL<br>

<input type="checkbox" name="elementprovince" value="KEP VILLE" id=
"optPROVINCE">KEP VILLE<br>

<input type="checkbox" name="elementprovince" value="KOH KONG" id=
"optPROVINCE">KOH KONG<br>

<input type="checkbox" name="elementprovince" value="KRATIE" id=
"optPROVINCE">KRATIE<br>

<input type="checkbox" name="elementprovince" value="MONDOL KIRI" id=
"optPROVINCE">MONDOL KIRI<br>

<input type="checkbox" name="elementprovince" value="ODORMEANCHEY" id=
"optPROVINCE">ODORMEANCHEY<br>

<input type="checkbox" name="elementprovince" value="PAILIN" id=
"optPROVINCE">PAILIN<br>

<input type="checkbox" name="elementprovince" value="PREAH VIHEAR" id=
"optPROVINCE">PREAH VIHEAR<br>

<input type="checkbox" name="elementprovince" value="PREY VENG" id=
"optPROVINCE">PREY VENG<br>

<input type="checkbox" name="elementprovince" value="PURSAT" id=
"optPROVINCE">PURSAT<br>

<input type="checkbox" name="elementprovince" value="RATTANAKIRI" id=
"optPROVINCE">RATTANAKIRI<br>

<input type="checkbox" name="elementprovince" value="SIEM REAP" id=
"optPROVINCE">SIEM REAP<br>

<input type="checkbox" name="elementprovince" value="SIHANOUK VILLE" id=
"optPROVINCE">SIHANOUK VILLE<br>

<input type="checkbox" name="elementprovince" value="STUNG TRENG" id=
"optPROVINCE">STUNG TRENG<br>

<input type="checkbox" name="elementprovince" value="SVAY RIENG" id=
"optPROVINCE">SVAY RIENG<br>

<input type="checkbox" name="elementprovince" value="TAKEO"
id="optPROVINCE"
>TAKEO<br>
<% *end* %>


 In this case i can search by each item or all item in form. I hope that
all
member in rubyonrails-talk will help me to solve this problem for me.

    thank in advance!
This topic is locked and can not be replied to.