0

i am passing radio button control id and getting radio button name. Using that i'm checking radio button[0] is checked. Its working good in IE 9 but not in IE Edge.

ABC.cshtml  
Yes  
@html.radiobuttonfor(m=>m.singlename,true,new{id="singleid",@onclick=bothchecked()})
No   
@html.radiobuttonfor(m=>m.singlename,false,new{id="singleid_no",@onclick=bothchecked() })

ABC.js file

function bothchecked()
{
  controls["singleid"];
  checksingle(controls);
  return false;
  break;
}

function checksingle(controls)
{
  var radio=document.getElementsByName(controls);
  if(radio[0].checked)
  {
  }
  else 
  {
    enablecontrols(controls);
  }
}

i'm getting error in this line if(radio[0].checked) where radio[0] is null or undefined.how to resolve it in IE Edge.

  • Possible duplicate of [Microsoft Edge: onclick event stops working?](http://stackoverflow.com/questions/33525721/microsoft-edge-onclick-event-stops-working) – Anoop H.N Mar 19 '17 at 07:49
  • Both controls seem to have the name `singlename`, yet you search (`getElementByName`) using `singleid` as a param. Is this a typo or I see it incorrectly? – Wiktor Zychla Mar 19 '17 at 07:51
  • its model name where im storing radiobutton value and its name of the radio controls too.. i gave diff name to id becoz i need to enable and disable the radio button using some condition @WiktorZychla – Sharmi Gayu Mar 19 '17 at 10:21
  • @SharmiGayu: could you show how your HTML looks like when rendered to the client (rather than the *.cshtml at the server)? – Wiktor Zychla Mar 19 '17 at 11:47

0 Answers0