Forum: Ruby on Rails How to take text_field value in a variable before form submit.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
2759e03bb5dd23536264645c7d54b120?d=identicon&s=25 Jitendra K. (jitendrakush)
on 2016-11-14 06:50
Hello friends,

I am new in ruby on rails, I want to take text_field value in a variable
then this variable value, I want to pass controller method throw
form_for method.

_employee.html.erb file

<div class="mydata1">
    <%= text_field :offer_id, { class: 'form-control', id: 'offer_id' }

<%= form_for :employee_details, :url =>{:controller => "hr", :action =>
"update", :offer_id =>2 } do |f| %>

  ------------ here my other code --------------------
<% end %>

I want to sent variable value in place ":offer_id => 2(variable value)".

JavaScript code on the same page:

<script type="text/javascript">

  // edit employee information
  $('#exampleModal1').on('', function (event) {

    var button = $(event.relatedTarget)
    var offer_id ='offer_id')

    var modal = $(this)
    modal.find('.mydata1 input').val(offer_id)

This topic is locked and can not be replied to.