Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

How to find the selected radio button immediately using the 'this' variable?

4 like 0 dislike
Hello

 How to find the selected radio button immediately using the 'this' variable?

Please give me your feedback.....
asked 1 year ago by daneim (127,080 points)

1 Answer

2 like 0 dislike
 
Best answer
<script>
function favAnimal(button) {
alert('You like '+button.value+'s.');
}
</script>
<input type="radio" name="marsupial" value="kangaroo"
onchange="favAnimal(this)">Kangaroo
<br /><input type="radio" name="marsupial" value="Opossum"
onchange="favAnimal(this)">Opossum
<br /><input type="radio" name="marsupial" value="Tasmanian Tiger"
onchange="favAnimal(this)">Tasmanian Tiger
answered 1 year ago by marck_don (191,010 points)

Related questions

4 like 0 dislike
1 answer
5 like 0 dislike
1 answer
5 like 0 dislike
0 answers
7 like 0 dislike
1 answer
5 like 0 dislike
1 answer