vfontjr icon

Hide/show fields based on anchorlink

vfontjr | PRO | 05/26/20 08:39:03 PM UTC | 0 ⭐ | 674 👁️ | Never ⏰ | []
jQuery |

1.09 KB

|

None

|

0 👍

/

0 👎

<script>
jQuery(document).ready(function($) {
    "use strict";
 
    $( function() {
        /* first make sure both field containers are not shown
         * you can also initially hide these fields by adding a class
         * to hide them in the fields' source code on the form's
         * Customize HTML page.
         * If using a class, comment out this code
         */
         
        /* first field container to hide
         * Change 152 to the id of your first field
         */
        $("#frm_field_152_container").hide();
        
        /* second field container to hide
         * Change 153 to the id of your first field
         */
        $("#frm_field_153_container").hide();
            
        /* get the url */
        var this_url = window.location.href;
        
        /* only process pages that pass the correct query string
         * change "#a" and "#b" to the names of the anchorlink you're passing
         * to this function in the url */
        if ( this_url.indexOf("#a") !== -1  || this_url.indexOf("#b") !== -1 ) {
        
            if ( this_url.indexOf("#a") !== -1 ) {
                $("#frm_field_152_container").show();
            } else {
                $("#frm_field_153_container").show();
            }
        }
    });
});
</script>

Comments