0

I have one Model Having two virtual Properties i.e

public virtual IEnumerable MediumIds { get; set; }
public virtual IEnumerable AnsLanguageIds { get; set; }

I have Used ViewBag To Populate Them i.e

ViewBag.MediumIds = db.ExamMediums.Where(x => x.ExamId == _ExamId).Select(x => x.Medium); ViewBag.AnsLanguageIds = new SelectList(db.AnswerLanguages.ToList(), "AnswerLanguageId", "AnsLanguage");

And My View Is

@foreach (var item in ViewBag.MediumIds) {

               <input id="MediumIds" name="MediumIds" value="@item.MediumId" type="checkbox"  /><strong>
                            @item.Medium1 </strong>

                        @Html.DropDownList("AnsLanguageIds")
                        <br />
                    }

I want The functionality like when the checkbox is selected than only the the dropdown should be enabled else it should be disabled and also i want that for which medium which anslanguage is selected

Your answer will be appreciated.

0

1 Answer 1

0

You can make the drop down lists disabled by default by passing new { disabled = "disabled" } as the DropDownList() method's htmlAttributes argument. This JQuery should toggle the select's disabled state when each checkbox is checked:

$(function() {
    $("input#MediumIds").click(function() {
        var checkbox = $(this);
        var dropDownlist = checkbox.sibling("select:first");
        dropDownlist.attr("disabled", checkbox.is(":checked") ? "" : "disabled");
    });
});

...I'm not sure what you mean by "i want that for which medium which anslanguage is selected"?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.