簡體   English   中英

如何在鏈接點擊時獲取參數值

[英]How to get params value in action on link click

我的查看代碼是

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
  <%= f.radio_button("amount", "10") %>
  <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
  <%= f.radio_button("amount", "20") %>
  <%= label :amount, '20 rs',:style => "display:inline" %><br>
  <%= f.radio_button("amount", "50") %>
  <%= label :amount, '50 rs',:style => "display:inline" %><br>
  <%= f.radio_button :amount, '100' %> 
  <%= label :amount, '100 rs',:style => "display:inline" %><br>    
  <%= link_to "Make Payment", verify_payment_payment_index_url, 
              :class => "btn",
              :data => { :toggle => "modal",
                         "target" => "#myBox" },
              "for"=>"Make Payment" %>

<% end %>

我想在點擊“付款”鏈接后訪問控制器操作中所有參數值。 那么如何在Rails 3中實現呢? 請注意,我必須點擊鏈接打開燈箱,然后提交表格

您需要提交表格! 因此,請嘗試以下操作:

<%= form_for(@payment,:url => verify_payment_payment_index_path) do |f| %>
   <%= f.radio_button("amount", "10") %>
   <%= label :amount, '10 Rs',:style => "display:inline" %> <br>
   <%= f.radio_button("amount", "20") %>
   <%= label :amount, '20 rs',:style => "display:inline" %><br>
   <%= f.radio_button("amount", "50") %>
   <%= label :amount, '50 rs',:style => "display:inline" %><br>
   <%= f.radio_button :amount, '100' %> 
   <%= label :amount, '100 rs',:style => "display:inline" %><br>

   <%= f.submit "Make Payment", :class=>"btn",:data => {:toggle => "modal","target"=>"#myBox"},"for"=>"Make Payment" %>

<% end %>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM