jquery - How to Reset the value for the enum radio button? -
i have written script function reset controls of page using jquery. got enum
public enum enumcurrencytype { [description("home currency")] homecurrency=1, [description("foreign currency")] foreigncurrency = 2, }
and cshtml page,
<div class="col-md-4 fnt-sz-1"> <label for="" class="control-label"> <b>currency type <font color="red">*</font></b></label><br /> <div class="radio col-md-4"> @html.enumradiobuttonfor(m => m.enumcurrencytype, false).disableif(() => model.isreadonly == true) </div> </div>
and reset button , function following
<input id="clickme" class="btn btn-default" type="button" value="reset" onclick="clearinput();" /> function clearinput(){ //clear text box value $('form input, form select').each(function(index) { var input = $(this); if (input.attr('type') == 'text') { input.val(''); } $("#enumcurrencytype").val(1); }); }
here don't know how reset enumcurrencytype control, please can please find solution
instead of
$("#enumcurrencytype").val(1);
try
$("#enumcurrencytype[value='1']").prop('checked',true);
or
$("#enumcurrencytype[value='1']").attr('checked','checked');
edit :-
as id in html generated enumradiobuttonfor()
_enumcurrencytype_homecurrency
,so try :-
$("#_enumcurrencytype_homecurrency[value='1']").prop('checked',true);
or
$("#_enumcurrencytype_homecurrency[value='1']").attr('checked','checked');
Comments
Post a Comment