I need to make this function work for a school project
which requires a form to be validated. The rest of the code works but I cannot seem to get this bit to. I need to make it so when one of the radio buttons is clicked a confirmation box is brought up, with the name of the button pressed.

Eg. "You have selected ______. Are You Sure"

The blank space is where the bit needs to be.
Then when cancel is pressed the radio buttons are all unchecked.

It also must be in one function. Any help would be appreciated.

Here is what I have so far:


<script language="JavaScript">
function checkbox() {
var confirmboxyes = confirm("You've selected. Are you sure?");

if ( confirmboxyes == false){
document.getElementById("1").checked = false;
document.getElementById("2").checked = false;
document.getElementById("3").checked = false;
return true
else {
return false;


<body bgcolor="pink">

<form name="form">
Cats <input type="radio" name="test" value="Cats" id="1" onclick="return checkbox()"> <br>
Dogs <input type="radio" name="test" value="Dogs" id="2" onclick="return checkbox()"> <br>
Birds <input type="radio" name="test" value="Birds" id="3" onclick="return checkbox()">