javascript - on specific click of radio button enable text-box/dropdown list in mvc using jquery -
i have 3 radio buttons , 1 dropdown list. on click third radio button dropdown list should appear else should disabled. how check condtion on third radio button based on 'id' property using jquery in mvc. me new jquery..
$("document").ready(function () { //this hide , disable dropdown on page load intially $("#ddsectionlsts").prop("disabled", true); $("#ddsectionlsts").hide(); $('input:radio').click(function () { //this hide , disable dropdown on click of radio button $("#ddsectionlsts").hide(); $("#ddsectionlsts").prop("disabled", true); if ($(this).val=="radiospecific") { //what suitable condtion check //on success of condition dropdown enabled selection $("#ddsectionlsts").show(); $("#ddsectionlsts").prop("disabled", false); } }); });
<body> <div> @html.radiobuttonfor(model => model.name1, new { @id = "radiocomman", @name="type", @class="test_css" }) cheque @html.radiobuttonfor(model => model.name2, new { @id = "radiospecific", @name = "type", @class = "test_css" })cas </div> @*drop down list*@ @{var listitems = new list<listitem> { new listitem { text = "exemplo1", value="exemplo1" }, new listitem { text = "exemplo2", value="exemplo2" }, new listitem { text = "exemplo3", value="exemplo3" } }; } @html.dropdownlist("exemplo", new selectlist(listitems, "value", "text"),new{ @id = "ddsectionlsts", @disabled = "disabled"}) </body>
$('input[name=type]').click(function(){ if ($(this).attr('id")=="radiospecific") { $("#ddsectionlsts").show(); $("#ddsectionlsts").prop("disabled", false); } else { $("#ddsectionlsts").hide(); $("#ddsectionlsts").prop("disabled", true); } });
Comments
Post a Comment