Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RadioButtonFor helper creates buttons with the same id, but I want to apply JQuery

I created with Razor 3 radiobuttons:

@Html.RadioButtonFor(model => model.SelectType, "Checking")
@Html.RadioButtonFor(model => model.SelectType, "Funds") 
@Html.RadioButtonFor(model => model.SelectType, "MoneyMarket")

Razor created the following HTML:

<input id="SelectType" name="SelectType" type="radio" value="Checking" /> 
<input id="SelectType" name="SelectType" type="radio" value="Funds" /> 
<input id="SelectType" name="SelectType" type="radio" value="MoneyMarket" /> 

Now I want to use JQuery to hide some options depending on which RadioButton was checked. I cannot do it, because each radiobutton has the same Id. Any ideas how to solve this problem?

Thanks,

z

like image 819
Zalek Bloom Avatar asked Dec 04 '25 10:12

Zalek Bloom


1 Answers

As tymeJV said just assign the id manually.

@Html.RadioButtonFor(model => model.SelectType, "Checking", new { id = "rbChecking" })
like image 187
asymptoticFault Avatar answered Dec 07 '25 13:12

asymptoticFault



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!