Javascript examples for DOM HTML Element:Input Radio
Input Radio checked Property - Find out if a radio button is checked or not:
<!DOCTYPE html> <html> <body> <p>Please choose the following:</p> <form action="#"> <input type="radio" name="coffee" value="cream">cream<br> <input type="radio" name="coffee" value="sugar">sugar<br> <br> <input type="button" onclick="myFunction()" value="Send order"> <br><br> <input type="text" id="order" size="50"> <input type="submit" value="Submit"> </form>//from www.j a v a2s.c o m <script> function myFunction() { var coffee = document.forms[0]; var txt = ""; var i; for (i = 0; i < coffee.length; i++) { if (coffee[i].checked) { txt = txt + coffee[i].value + " "; } } document.getElementById("order").value = txt; } </script> </body> </html>