Hide and show cascading dropdown using JQuery in SharePoint
<script src="http://code.jquery.com/jquery-1.9.1.js"></script><script type="text/javascript">
function PreSaveAction()
{
var sRiskType=$("select[title^='Risk Type']");
var sRiskStatus=$("select[title^='Risk Status']");
var sOpportunityStatus=$("select[title^='Opportunity Status']");
if((sRiskType.val()=="Risk")&&(sRiskStatus.val()==""))
{
alert('Please select Risk Status ');
return false;
}
else if((sRiskType.val()=="Opportunity")&&(sOpportunityStatus.val()==""))
{
alert('Please select Opportunity Status ');
return false;
}
return true;
}
$(document).ready(function() {
$('nobr:contains("Risk Status")').closest('tr').hide();
$('nobr:contains("Opportunity Status")').closest('tr').hide();
$("select[title^='Risk Type']").change(function(){
if ($(this).val() != 'Risk') {
$('nobr:contains("Risk Status")').closest('tr').hide();
}
else {
$('nobr:contains("Risk Status")').closest('tr').show();
}
if ($(this).val() != 'Opportunity') {
$('nobr:contains("Opportunity Status")').closest('tr').hide();
}
else {
$('nobr:contains("Opportunity Status")').closest('tr').show();
}
return false;
});
});
</script>
function PreSaveAction()
{
var sRiskType=$("select[title^='Risk Type']");
var sRiskStatus=$("select[title^='Risk Status']");
var sOpportunityStatus=$("select[title^='Opportunity Status']");
if((sRiskType.val()=="Risk")&&(sRiskStatus.val()==""))
{
alert('Please select Risk Status ');
return false;
}
else if((sRiskType.val()=="Opportunity")&&(sOpportunityStatus.val()==""))
{
alert('Please select Opportunity Status ');
return false;
}
return true;
}
$(document).ready(function() {
$('nobr:contains("Risk Status")').closest('tr').hide();
$('nobr:contains("Opportunity Status")').closest('tr').hide();
$("select[title^='Risk Type']").change(function(){
if ($(this).val() != 'Risk') {
$('nobr:contains("Risk Status")').closest('tr').hide();
}
else {
$('nobr:contains("Risk Status")').closest('tr').show();
}
if ($(this).val() != 'Opportunity') {
$('nobr:contains("Opportunity Status")').closest('tr').hide();
}
else {
$('nobr:contains("Opportunity Status")').closest('tr').show();
}
return false;
});
});
</script>
Comments
Post a Comment