I have a radio button
@Html.RadioButtonFor(model => model.flag, "RA", htmlAttributes: new { @id = "Roflag2", })
Call for Addl. Particulars
and a div
IF radio button is clicked then this div shown otherwise hide,
How can i do this?
I have a radio button
@Html.RadioButtonFor(model => model.flag, "RA", htmlAttributes: new { @id = "Roflag2", })
Call for Addl. Particulars
and a div
IF radio button is clicked then this div shown otherwise hide,
How can i do this?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ali BenchaabanPosted Jan 5, 2024, 12:00 PM
Hello,
Use this code within your ASP.NET code
Regards,
BENCHAABAN Ali
Naimish MakwanaPosted Jan 5, 2024, 12:20 PM
You can use jQuery to achieve this. Here’s a simple example:
In this code, we’re using the
changeevent to detect when the radio button’s state changes. If the radio button is checked (this.checkedistrue), we show the div with$('#callfor').show(). If the radio button is not checked, we hide the div with$('#callfor').hide().Please note that this code assumes that you have included the jQuery library in your project. If you haven’t, you can include it with the following line in your HTML file:
This line should be placed in the
section of your HTML file. If you’re already using a different version of jQuery, you don’t need to include this line.Also, please ensure that the radio button and the div have the correct ids (
Roflag2andcallforrespectively) as specified in the jQuery selectors ($('#Roflag2')and$('#callfor')). If the ids are different, you should replaceRoflag2andcallforwith the actual ids.This code should be placed in a
tag either in thesection (if you’re using$(document).ready()) or at the end of thesection of your HTML file.Remember to test this code thoroughly to ensure it works as expected in your specific application context. Let me know if you have any questions!
Thanks
Garima BansalPosted Jan 5, 2024, 11:08 AM
below is the div
@if (Model.remarkscrunity == "Y")
{
@Html.ActionLink("General Remarks", "remarkscrunity", "Inspection", new { @applnno = Model.applnno }, htmlAttributes: new { @class = "btn btn-orange turbolinks", style = "font-size: 18px", @HttpMethodConstraint = "Post" }) ✔
}
else
{
@Html.ActionLink("General Remarks", "remarkscrunity", "Inspection", new { @applnno = Model.applnno }, htmlAttributes: new { @class = "btn btn-orange turbolinks", style = "font-size: 18px", @HttpMethodConstraint = "Post" })
}