0

I have following code in my view:

<span class="pull-right">
      <%= link_to 'Siblings', siblings_path(cnic: '21303-51235-5'), id: 'view_siblings' %>
</span>
<%= f.text_field :cnic, class: "form-control" %>

As for now i have given fixed value to cnic parameter. What i want is:

If user type his cnic then this user input should be sent as parameter to siblings_path.

How can i do that?

3
  • you need a litlle bit javascript.. or you can change with a form.. Commented Jul 8, 2018 at 4:52
  • How can i do that via javascript? Commented Jul 8, 2018 at 4:59
  • why not wrap it in a form? Commented Jul 8, 2018 at 6:28

1 Answer 1

1
$(".form-control").change(function(e) {
  $("#view_siblings").prop("href", siblings_path + "?cnic=" + e.target.value);
  // replace siblings_path with actual url
})
Sign up to request clarification or add additional context in comments.

1 Comment

While this may answer the question, add some description how it solves the problem. It helps future readers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.