Click here to Skip to main content
15,886,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have drop down list with following values(in which first two values shows payment status).Its on Admin side of my project.
1)Unpaid
2)Paid
3)Delivered

First two values are depended upon Payment Status.
Here,I want to Enable='false' to 'Unpaid' if the payment status is 'Paid' & Enable='false' for both 'Unpaid and 'Paid' if Status is 'Delivered'.
So how to enable selection false to these two values(Unpaid & Paid) so that Admin cannot change status to Unpaid or Paid by himself.He can only see it. But he can change it to "Delivered"
Please help.
Posted
Updated 19-Jan-15 23:58pm
v2

You can add javascript onchange() event on dropdown check to display alert message for improper selected value and display the current value selected in dropdownbox.
e.g. if admin change value from "Paid" to "Unpaid" or "Unpaid" to "Paid" simple shows alert message like "select proper value" and show current value selected in it.
 
Share this answer
 
Comments
Ankita1391 20-Jan-15 6:49am    
thanks :)
Try this:
XML
<form id="form1" runat="server">
<div>
    <asp:DropDownList ID="ddl1" runat="server" onChange="onChange();" AutoPostBack="False">
        <asp:ListItem></asp:ListItem>
        <asp:ListItem>Unpaid</asp:ListItem>
        <asp:ListItem>Paid</asp:ListItem>
        <asp:ListItem>Delivered</asp:ListItem>
    </asp:DropDownList>
</div>
</form>
<script>
    var ddl = document.getElementById("<%= ddl1.ClientID %>");
    function onChange() {
        var selectedIndex = ddl.selectedIndex;
        var selectedOption = ddl.options[selectedIndex];
        for (var i = 0; i < ddl.length; i++) {
            if (ddl.options[i].value == "Unpaid" && selectedOption.value == "Paid") {
                ddl.options[i].disabled = true;
                break;
            } else if (selectedOption.value == "Delivered") {

                if (ddl.options[i].value == "Unpaid" || ddl.options[i].value == "Paid") {
                    ddl.options[i].disabled = true;

                }
            }
        }
    }

    function disableOption(i) {
        ddl.options[i].disabled = true;
    }
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900