Js method to get the value of type=radio

  • 2020-03-30 02:56:42
  • OfStack

 
<ul> 
<li> 
<input type="radio" name="radio" value=" The front desk to pay  " id="radio" /> The front desk to pay   If you want to keep the room overnight, please pay in advance.  
</li> 
<li> 
<input type="radio" name="radio" value=" Guarantee payment " id="radio" /> Guarantee payment   -- the customer service staff will call you later.  
 And confirm the information required for the warranty.  
</li> 
</ul> 

 
var chkObjs=null; 

var obj=document.getElementsByName("radio")
for (var i=0;i<obj.length;i++){ //Traverse the Radio
if(obj[i].checked){ 
chkObjs=obj[i].value; 
} 
} 
alert(chkObjs); 

Related articles: