PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Get Value from Drop Down Select Box

  1. So i have done pretty well getting this to work on my test form. My form is able to put whatever is select in the drop down box in the text field below. But I am pulling the drop down value from a product drop box. So the value coming back is "Second Choice| 199" I need a way to separate this into two separate boxes. So "Second Choice" is in one text box and "199" Is in a seperate text box. Ultimately this is going to be an order summary on the sidebar of my page. This is very specific to what my client wants.
    Link to the test form: http://ineedapassport.com/test/

    Please help!

    Posted 11 years ago on Sunday October 14, 2012 | Permalink
  2. Ok so I am thinking of having the return value go to a hidden field then have jquery split the value from there into the two separate fields I want? Any thoughts?

    Posted 11 years ago on Sunday October 14, 2012 | Permalink
  3. Bumping this to see if anyone can help me. Any one?

    Posted 11 years ago on Monday October 15, 2012 | Permalink
  4. Ok well since I couldn't get any help on here with this I went outside of here and got the answer. I though I would post it here just in case someone else needs it. This takes the value from a product drop box and splits into 2 different text fields. For example "Second Choice| 199" is split at the "|".

    add_filter("gform_pre_render_3", "monitor_dropdown");
    function monitor_dropdown($form){
    
    ?>
        <scr ipt type="text/java script">
    function the_form(str,varr)
    {
    var n=str.split("|");
    if(varr==1) return n[0]; else return n[1];
    }
    jQuery(document).ready(function(){
    jQuery('#input_3_1').bind('change', function()
    {
    //get selected value from drop down;
    var selectedValue = jQuery("#input_3_1").val();
    //populate a text field with the selected drop down value
    //this will populate it with the text part of the selected value
    jQuery("#input_3_2").val(the_form(selectedValue,1));
    jQuery("#input_3_3").val(the_form(selectedValue,2));
    });
    });
    </script>
    <?php
    
    return $form;
    }

    [chrishajer: broke the words script and javascript to get them to pass through firehost security filter]

    Posted 11 years ago on Monday October 15, 2012 | Permalink
  5. Thank you for posting your solution.

    Posted 11 years ago on Tuesday October 16, 2012 | Permalink