user64134
user64134

Reputation: 21

ASP Form problem

I have an asp form that has a checkbox and dropdown menu. If the checkbox in not selected then I need to make sure the dropdown is either not selected or disabled.

Upvotes: 2

Views: 168

Answers (2)

cgreeno
cgreeno

Reputation: 32381

You either need to PostBack on a the check changed event or disable it using JavaScript

On your checkbox add onchange="checkChanged()"

Then you need to add the javascript function

function checkChanged()
{
    if(Document.GetElementById('mycheckBox').Checked)
        Document.GetElementById('myDropdown').disabled = true;
    else
         Document.GetElementById('myDropdown').disabled = false;
}

Upvotes: 2

Frost
Frost

Reputation: 883

You should make a javascript to check if the checkbox is checked or not, and then enable/disable the dropdown?
You can do this using jQuery, you need to wrap a function that gets called arround it:

if ($("#checkbox").attr("checked")) {
    $("#dropdown").attr("disabled", true);
}
else
{
    $("#dropdown").attr("disabled", false);
}

Upvotes: 2

Related Questions