adding filter search inside of a form so it can post data












0















I am currently learning ruby and am trying to add a filter/search bar like this one https://www.w3schools.com/howto/howto_js_filter_lists.asp. Inside of a form. so in theory I could get one of the params from the filter search and other params from user input.



<h1>Add a new coin to your Coinfolio</h1>
<form id = "post-form" method = "post" action = "/coins">


<input type="text" id="coin-search-bar" onkeyup="myFunction()" placeholder="Search for coins..">

<ul id="available-coin-list">
<% @available_coins.each_with_index do |coin, index| %>
<li>
<a>
<%= coin.name %> price = $ <%= coin.current_price %>
<input type = "text" name = "price_paid" placeholder="price paid:"/>
<input type = "hidden" name = "coin_id" value = "<%= coin.id %>">
<input type = "submit">
</a>
</li>

<% end %>
</ul>
</form>


this is what I have so far however im not getting any values in the params hash who clicking submit. also would rather be able to have only one search button and input field. Any ideas how i can accomplish this.










share|improve this question





























    0















    I am currently learning ruby and am trying to add a filter/search bar like this one https://www.w3schools.com/howto/howto_js_filter_lists.asp. Inside of a form. so in theory I could get one of the params from the filter search and other params from user input.



    <h1>Add a new coin to your Coinfolio</h1>
    <form id = "post-form" method = "post" action = "/coins">


    <input type="text" id="coin-search-bar" onkeyup="myFunction()" placeholder="Search for coins..">

    <ul id="available-coin-list">
    <% @available_coins.each_with_index do |coin, index| %>
    <li>
    <a>
    <%= coin.name %> price = $ <%= coin.current_price %>
    <input type = "text" name = "price_paid" placeholder="price paid:"/>
    <input type = "hidden" name = "coin_id" value = "<%= coin.id %>">
    <input type = "submit">
    </a>
    </li>

    <% end %>
    </ul>
    </form>


    this is what I have so far however im not getting any values in the params hash who clicking submit. also would rather be able to have only one search button and input field. Any ideas how i can accomplish this.










    share|improve this question



























      0












      0








      0








      I am currently learning ruby and am trying to add a filter/search bar like this one https://www.w3schools.com/howto/howto_js_filter_lists.asp. Inside of a form. so in theory I could get one of the params from the filter search and other params from user input.



      <h1>Add a new coin to your Coinfolio</h1>
      <form id = "post-form" method = "post" action = "/coins">


      <input type="text" id="coin-search-bar" onkeyup="myFunction()" placeholder="Search for coins..">

      <ul id="available-coin-list">
      <% @available_coins.each_with_index do |coin, index| %>
      <li>
      <a>
      <%= coin.name %> price = $ <%= coin.current_price %>
      <input type = "text" name = "price_paid" placeholder="price paid:"/>
      <input type = "hidden" name = "coin_id" value = "<%= coin.id %>">
      <input type = "submit">
      </a>
      </li>

      <% end %>
      </ul>
      </form>


      this is what I have so far however im not getting any values in the params hash who clicking submit. also would rather be able to have only one search button and input field. Any ideas how i can accomplish this.










      share|improve this question
















      I am currently learning ruby and am trying to add a filter/search bar like this one https://www.w3schools.com/howto/howto_js_filter_lists.asp. Inside of a form. so in theory I could get one of the params from the filter search and other params from user input.



      <h1>Add a new coin to your Coinfolio</h1>
      <form id = "post-form" method = "post" action = "/coins">


      <input type="text" id="coin-search-bar" onkeyup="myFunction()" placeholder="Search for coins..">

      <ul id="available-coin-list">
      <% @available_coins.each_with_index do |coin, index| %>
      <li>
      <a>
      <%= coin.name %> price = $ <%= coin.current_price %>
      <input type = "text" name = "price_paid" placeholder="price paid:"/>
      <input type = "hidden" name = "coin_id" value = "<%= coin.id %>">
      <input type = "submit">
      </a>
      </li>

      <% end %>
      </ul>
      </form>


      this is what I have so far however im not getting any values in the params hash who clicking submit. also would rather be able to have only one search button and input field. Any ideas how i can accomplish this.







      javascript html ruby html5






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 17:49







      harry

















      asked Nov 13 '18 at 17:13









      harryharry

      194




      194
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Im learning too, but this is how I implemented a search bar into my navbar. maybe helps. This code is a partial html.erb that I render into my navbar.html.



          <div class="advanced_search_container">
          <div class="input-group" id="adv-search">
          <%= form_tag(dresses_path, {class: 'search form-inline my-2 my-lg-0', method: 'get'}) do %>
          <%= text_field_tag :search, '', class: " mr-sm-2", placeholder: "Find The Dress" %>
          <%= select_tag :size, options_for_select(Dress::SIZES), :prompt => "size", class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;"%>
          <%= select_tag :category, options_for_select(Dress::CATEGORIES), :prompt => "category" , class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;" %>
          <%= submit_tag 'Search', class: " search btn btn-outline-success my-2 my-sm-0 "%>
          <% end %>
          </div>







          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286314%2fadding-filter-search-inside-of-a-form-so-it-can-post-data%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Im learning too, but this is how I implemented a search bar into my navbar. maybe helps. This code is a partial html.erb that I render into my navbar.html.



            <div class="advanced_search_container">
            <div class="input-group" id="adv-search">
            <%= form_tag(dresses_path, {class: 'search form-inline my-2 my-lg-0', method: 'get'}) do %>
            <%= text_field_tag :search, '', class: " mr-sm-2", placeholder: "Find The Dress" %>
            <%= select_tag :size, options_for_select(Dress::SIZES), :prompt => "size", class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;"%>
            <%= select_tag :category, options_for_select(Dress::CATEGORIES), :prompt => "category" , class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;" %>
            <%= submit_tag 'Search', class: " search btn btn-outline-success my-2 my-sm-0 "%>
            <% end %>
            </div>







            share|improve this answer




























              0














              Im learning too, but this is how I implemented a search bar into my navbar. maybe helps. This code is a partial html.erb that I render into my navbar.html.



              <div class="advanced_search_container">
              <div class="input-group" id="adv-search">
              <%= form_tag(dresses_path, {class: 'search form-inline my-2 my-lg-0', method: 'get'}) do %>
              <%= text_field_tag :search, '', class: " mr-sm-2", placeholder: "Find The Dress" %>
              <%= select_tag :size, options_for_select(Dress::SIZES), :prompt => "size", class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;"%>
              <%= select_tag :category, options_for_select(Dress::CATEGORIES), :prompt => "category" , class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;" %>
              <%= submit_tag 'Search', class: " search btn btn-outline-success my-2 my-sm-0 "%>
              <% end %>
              </div>







              share|improve this answer


























                0












                0








                0







                Im learning too, but this is how I implemented a search bar into my navbar. maybe helps. This code is a partial html.erb that I render into my navbar.html.



                <div class="advanced_search_container">
                <div class="input-group" id="adv-search">
                <%= form_tag(dresses_path, {class: 'search form-inline my-2 my-lg-0', method: 'get'}) do %>
                <%= text_field_tag :search, '', class: " mr-sm-2", placeholder: "Find The Dress" %>
                <%= select_tag :size, options_for_select(Dress::SIZES), :prompt => "size", class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;"%>
                <%= select_tag :category, options_for_select(Dress::CATEGORIES), :prompt => "category" , class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;" %>
                <%= submit_tag 'Search', class: " search btn btn-outline-success my-2 my-sm-0 "%>
                <% end %>
                </div>







                share|improve this answer













                Im learning too, but this is how I implemented a search bar into my navbar. maybe helps. This code is a partial html.erb that I render into my navbar.html.



                <div class="advanced_search_container">
                <div class="input-group" id="adv-search">
                <%= form_tag(dresses_path, {class: 'search form-inline my-2 my-lg-0', method: 'get'}) do %>
                <%= text_field_tag :search, '', class: " mr-sm-2", placeholder: "Find The Dress" %>
                <%= select_tag :size, options_for_select(Dress::SIZES), :prompt => "size", class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;"%>
                <%= select_tag :category, options_for_select(Dress::CATEGORIES), :prompt => "category" , class: "select", style: "border-bottom:0px solid !important; margin-left:5px;width: 70px;" %>
                <%= submit_tag 'Search', class: " search btn btn-outline-success my-2 my-sm-0 "%>
                <% end %>
                </div>








                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 13 '18 at 17:55









                Andrea BazánAndrea Bazán

                488




                488






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53286314%2fadding-filter-search-inside-of-a-form-so-it-can-post-data%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Florida Star v. B. J. F.

                    Danny Elfman

                    Lugert, Oklahoma