Radio Button and looping

I tried this one for some experiment and I can't seem to work it out can you help me about this?
The problem here is that when you click on the Radio button then click the result button it should give an alert with number(this number is how may times youve clicked the result button with the radio button on)
This is my code use:

Nicely done thanks.. I will try this. Really thanks.
Also how am I supposed to do this using text boxes, for example I clicked the first one then submit the first text box should show how many numbers I voted as well as the second box with the second button.

This is slighltly tricky, and there are many ways to write the code. It's hard for me to describe exatly what to do without actually writing it for you but here goes.

In HTML:

Give the radio buttons id="radio_x" , where x is 0,1,2 etc.

Create one input field per radio button, to display the respective vote totals. Make the input fields type="text" , size="3" , disabled (to avoid a false indication that user-input is invited), value="0" , and id="count_x" , where x is 0,1,2 etc. By giving each count field an id with the same suffix as that of its radio button, you can form a rule in Javascript to determine the id of the count field corresponding to the currently selected radio button (by taking the id of the current radio button and replacing "radio" with "count").

Give each voting option a label to indicate to the user what is being voted for.

Change the value of the "Result" button to "Vote".

In Javscript:

You no longer need var count . The totals will be stored in the input fields (one per voting option). There's no need to maintain totals in Javascript as well.

Create a var currentCountFieldId to track which radio button is currently selected. This avoids having to loop through all voting options when the "Vote" button is pressed.

Attach an onclick handler (ie. function) to each radio button, to set currentCountField to that radio button's id.

Modify the document.test.result.onclick handler to apply the rule to work out the id of the count field corresponding to currentCountFieldId (use currentCountFieldId.replace("radio", "count") ), then document.getElementById() to find the DOM element. Read its current value, convert it to a number (use Number([I]element[/I].value) ), add 1 then write it back to the same field you just read it from. With a bit of thought, much of this can be performed in one line, wrapped in a protective if(){....} to avoid an error should the user try to "Vote" before an option is selected.

Formulate all your javascript within onload = function() {...} to avoid using the global namespace.

Should be no more than 20 lines of javascript (I just did it in 14 including the onload wrapper and a further four lines with no more than a closing } ).