mercredi 21 juin 2017

Print checkbox value onclick javascript / jquery

i need to replace the value of my button "Type de travaux" with the checkbox value on click. I tried lot of things but JS is not my religion ;)

  <div class="form_home">
  <%= simple_form_for(@client) do |f| %>
    <div class="home_container">
      <div class="main-form-stuffs">
      <%= f.input :address, placeholder: 'Ville, CP, Adresse', autofocus: true, label:false %>
      </div>
      <div class="dropdown main-form-stuffs">
        <button class="btn btn-default custom-drop-down-btn dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
          Type de travaux
          <span class="caret"></span>
        </button>
        <ul class="dropdown-menu dropdown-size-custom" aria-labelledby="dropdownMenu1">
          <li><label><%= f.check_box :couverture %> <span> couverture</span></label></li>
          <li><label><%= f.check_box :charpente %><span> charpente</span></label></li>
          <li><label><%= f.check_box :ouverture %> <span> fenêtre / ouverture</span></label></li>
          <li><label><%= f.check_box :terrasse %><span> terrasse</span></label></li>
          <li><label><%= f.check_box :plomberie %><span> eaux de pluies / zinguerie</span></label></li>
        </ul>
      </div>
      <div class="dropdown main-form-stuffs">
        <button class="btn btn-default custom-drop-down-btn dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
          Type de bien
          <span class="caret"></span>
        </button>
        <ul class="dropdown-menu dropdown-size-custom" aria-labelledby="dropdownMenu1">
          <li><label><%= f.check_box :maison %><span> maison</span></label></li>
          <li><label><%= f.check_box :immeuble %><span> immeuble</span></label></li>
          <li><label><%= f.check_box :chateau %><span> chateau</span></label></li>
          <li><label><%= f.check_box :monument_historique %><span> monument historique</span></label></li>
        </ul>
      </div>
      <div class="dropdown main-form-stuffs">
        <button class="btn btn-default custom-drop-down-btn dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
          Besoin
          <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
          <li><label><%= f.check_box :construction %><span> construction</span></label></li>
          <li><label><%= f.check_box :renovation %><span> rénovation</span></label></li>
          <li><label><%= f.check_box :entretien %><span> entretien</span></label></li>
        </ul>
      </div>
      <div class="main-form-stuffs">
        <%= button_tag type: 'submit', class: "search-button" do %>
        <i class="fa fa-search" aria-hidden="true"></i>
        <% end %>
      </div>
    </div>
  <% end %>
  </div>

I need to change this value before submitting the form

Thanks for your help!!!




Aucun commentaire:

Enregistrer un commentaire