Wednesday, November 16, 2016

Checking selected value in all dropdowns using jquery


Below code works if you have multiple drop downs where you want to check the selected value in all drop downs  in the form and see if this value is selected already, if selected then will show an alert message and change the selected value of that particular drop down


Add the "OnChange" in dropdown events as this onchange="ChkCurrent(this);
where 'id' is current value dropdown
 function ChkCurrent(id) {   
            var ddlValues = new Array();
            $("[id*='ddlstsCurrM']").each(function (i) {
                if ($(this).val()== 1) {
                    ddlValues.push($(this).val());
                }

            });
            if (ddlValues.length > 1)
            {
                alert("This value has been already selected");
                var ddlid ="#"+id.id;
                $(ddlid).val('0');

            }
        }

SharePoint - Cannot convert a primitive value to the expected type 'Edm.Double'. See the inner exception for more details If y...

Ad