jQuery – Changing href When Drop-down Selection Changes

I needed to provide a different template depending on the type of activity selected in a drop-down menu. The following jQuery code gets the template name from the drop-down value and updates the href target.

jQuery("#selectDivSetType").change(function () {     
    var strTemplateName = $('#selectDivSetType').val();
    var strTemplateURI = './templates/' + strTemplateName;
    $('#templateURI').attr("href", strTemplateURI); 
});

Leave a Reply

Your email address will not be published. Required fields are marked *