Hi,
Can someone help me with the following questions. I am trying to create
a link_to_remote link named add. Whenever I click add, a new label and
text field will be populated.
Example:
(This is already there)
Book 1       text_field     add(this is the link)
....when add is clicked..............
.....the following is populated........
Book 2       text_field
My question is how do I increment the number? How do I submit the
various fields, populated and the one that is already there, that are in
the form ? I read some where that it has to do with the id of the field.
This is my controller
def book
  @book = Book.new
end
def save_book
   @book = Book.new(params[:book])
      if @book.save
        redirect_to :action => ''some_page''
      else
        render :action=> ''book''
    end
  end
def add_book
 @count = 1
   render(:partial => ''additional_book'')
end
This is my view
......_additional_book.rhtml.........
<tr>
<td style="width: 374px;"><label>Book <%= @count
%></label></td>
<td style="width: 219px;"><%= text_field :book, :book, :id
=> @count
%></td>
</tr>
.......book.rhtml................
<div id="content">
<% form_for :book, :url => { :action => :save_book}, :html => { :id
=>
"book" } do |n| %>
  <table style="width: 685px; height: 171px;">
    <tbody id="abc">
      <tr>
        <td style="width: 374px;"><label>Book
0</label></td>
        <td style="width: 219px;"><%= n.text_field :book
%> <%link_to_remote( "add", :update => "abc", :url
=>{ :action => :add_book
}, :position => "bottom", :success => "@count ++")
%></td>
    </tr>
    <tr>
      <td style="width: 209px;">
        <div id="button">
    <p><%= link_to_function ''Previous'',
"$(''book'').submit()" -%></p>
        </div>
  </td>
      </tr>
    </tbody>
  </table>
<% end %>
</div>
-- 
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
-~----------~----~----~----~------~----~------~--~---
user splash wrote:> Hi, > > Can someone help me with the following questions. I am trying to create > a link_to_remote link named add. Whenever I click add, a new label and > text field will be populated. > > > Example: > > (This is already there) > Book 1 text_field add(this is the link)Hi, Any help for the above questions will be appreciated. Thanks -- 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 someone help me with the following questions. I am trying to create
a link_to_remote link named add. Whenever I click add, a new label and
text field will be populated.
Example:
(This is already there)
Book 1       text_field     add(this is the link)
....when add is clicked..............
.....the following is populated........
Book 2       text_field
My question is how do I increment the number? How do I submit the
various fields, populated and the one that is already there, that are in
the form ? I read some where that it has to do with the id of the field.
This is my controller
def book
  @book = Book.new
end
def save_book
   @book = Book.new(params[:book])
      if @book.save
        redirect_to :action => ''some_page''
      else
        render :action=> ''book''
    end
  end
def add_book
 @count = 1
   render(:partial => ''additional_book'')
end
This is my view
......_additional_book.rhtml.........
<tr>
<td style="width: 374px;"><label>Book <%= @count
%></label></td>
<td style="width: 219px;"><%= text_field :book, :book, :id
=> @count
%></td>
</tr>
.......book.rhtml................
<div id="content">
<% form_for :book, :url => { :action => :save_book}, :html => { :id
=>
"book" } do |n| %>
  <table style="width: 685px; height: 171px;">
    <tbody id="abc">
      <tr>
        <td style="width: 374px;"><label>Book
0</label></td>
        <td style="width: 219px;"><%= n.text_field :book
%> <%link_to_remote( "add", :update => "abc", :url
=>{ :action => :add_book
}, :position => "bottom", :success => "@count ++")
%></td>
    </tr>
    <tr>
      <td style="width: 209px;">
        <div id="button">
    <p><%= link_to_function ''Previous'',
"$(''book'').submit()" -%></p>
        </div>
  </td>
      </tr>
    </tbody>
  </table>
<% end %>
</div>
Thanks
-- 
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
-~----------~----~----~----~------~----~------~--~---