skip to Main Content

I want something like when I select a value on the drop-down list, that particular value has to show on my submit button. Please check the link below for what I mean
https://www.elefant-tours.de/ueber-uns/reiseanmeldung/?wetu_id=15FAC4B2-C939-4179-918D-E3140BA3177E

2

Answers


  1. Example of that behavior with jquery.
    You need to match the select id
    and also insert a span tag inside the button with a matching class

    Live example:
    https://jsfiddle.net/1qjvtc86/

    From gravityforms site:

    there is an easy way to add custom Javascript to your Gravity Forms
    that only loads when the form is rendered. Just copy-and-paste your
    desired snippet into the robust editor on your Form Settings and
    you’re golden.

    <div>
        <select id="picker">
            <option value="5">5 items</option>
            <option value="4">4 items</option>
            <option value="3">3 items</option>
            <option value="2">2 items</option>
            <option value="1">1 items</option>
        </select>
    </div>
    <div>
        <button>user picked <span class="pickedAmount">1</span> items</button>
    </div>
    
    
    <!-- copy this into gravity form -->
    <script>
    // picker - is the ID of the select
    // pickedAmount - is the CLASS of the span 
    jQuery(function($){
     
        $('#picker').on('change', function() {
            $('.pickedAmount').text($(this).val());
        })
    
    });
    </script>
    <!-- copy this into gravity form -->
    
    Login or Signup to reply.
  2. Your JavaScript solution is:

    function my_fun(obj){
       alert(obj.options[obj.selectedIndex].text);
    }
    <select onchange="my_fun(this)">
       <option>item one(1)</option>
       <option>item two(2)</option>
       <option>item three(3)</option>
       <option>item four(4)</option>
       <option>item five(5)</option>
    </select>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search