This article example describes how to simply obtain radio button values in a form by JS. Share it for your reference, as follows:
The HTML part is as follows:
<form><tr bgcolor="#FFFFFF"> <td rowspan="3" align="center" valign="middle" bordercolor="#999999"><span>Rollback type:</span></td> <td align="center" valign="middle" bordercolor="#999999"><input type="radio" name="returnTag" value="-1" checked="checked"> Reporting Department</td></tr><tr bgcolor="#FFFFFF"> <td align="center" valign="middle" bordercolor="#999999"><input type="radio" name="returnTag" value="1"> Provincial Network Tendering Center</td></tr><tr bgcolor="#FFFFFF"> <td align="center" valign="middle" bordercolor="#999999"><input type="radio" name="returnTag" value="2"> State Grid Tendering Center</td></tr></form1>
The JS code is as follows:
function getValue(){//Get the radio button value for(var i=0;i<form1.returnTag.length;i++) { if(form1.returnTag[i].checked) { var returnTagValue=form1.returnTag[i].value; //Get the radio button value here} }}For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Data Structure and Algorithm Skills", "Summary of JavaScript traversal algorithms and techniques", "Summary of json operation techniques in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques" and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.