Hi,
I have a View page called: radio_page.cshtml, it contains two radio buttons. First radio button is checked as default when loading the page. I need when clicking on second radio button to refresh the page and keep selection on second radio button, I am trying that as below, but it does not work. After refreshing the page the selection returns to the first radio button. Please advise. Thanks.
//In View
@Html.RadioButtonFor(m=>m.Value, "KW", new { style = "width:70px", @onClick = "onRadioClick(this);", @checked = "checked" }) KW
@Html.RadioButtonFor(m=>m.Value, "HP", new { style = "width:70px", @onClick = "onRadioClick(this);&" })HP
//JavaScript-In Javascript onradio button click textboxes will be hide & show.
<script type="text/javascript">
function onRadioClick(e)
{
var SelectedValue = e.value;
if (SelectedValue == "HP")
{
document.getElementById("DvHP").style.visibility = "Visible";
document.getElementById("DvKW").style.visibility = "hidden";
}
else {
document.getElementById("DvHP").style.visibility = "hidden";
document.getElementById("DvKW").style.visibility = "Visible";
}
}
</script>