If yes is selected display additional fields

Discussion in 'aMember Pro v.4' started by vacc_webmaster, Oct 15, 2012.

  1. vacc_webmaster

    vacc_webmaster Member

    Joined:
    Jan 24, 2007
    Messages:
    51
    I added two custom fields:

    Show in public member directory?
    Do you offer supervision?

    The defaults are No but if the user selects YES I would like them to either:
    a) sent to a multi-page with additional fields or
    b) on the same page show additional fields immediately after selecting YES from

    What code or how would I make this happen?
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    I am afraid I can give wrong code without debugging, but I would implement something like that in JQuery:

    PHP:
    <script type='text/javascript'>
    $(function(){  
    // jquery onload
    $("select[name='yesfield']").change(function(){ // code to be called on "yesfield" changed
       
    var showFlag = $(this).val() == 'YES'// will be set to true if <select name="yesfield"> has option YES selected
       
    $("input[name='optional-field1']").closest(".row").toggle(showFlag); // hide or show row containing optional-field1
       
    $("select[name='optional-field2']").closest(".row").toggle(showFlag); // hide or show row containing select optional-field2
    /// and so on
    }); // end of code to be called on "yesfield" changed
    }); // end of jquery onload
    </script>
    You may need to create additional template signup_custom.phtml (copy from signup.phtml) in amember/application/default/views/signup/ and add javascript code inside.
    then select that template at aMember CP -> Setup -> Forms Editor for your signup form.

Share This Page