Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
150
rated 0 times [  152] [ 2]  / answers: 1 / hits: 24706  / 13 Years ago, thu, may 5, 2011, 12:00:00

I need some help please
This is the html



<div>
<p>match1</p>
teamA <input type=radio name=match1 onclick=update('ab'); />
teamB <input type=radio name=match1 onclick=update('ba'); />
<p>match2</p>
teamC <input type=radio name=match1 onclick=update('ad'); />
teamD <input type=radio name=match1 onclick=update('dc'); />
</div>


<script>
update(results){.................}
</script>


I have this html so what I want I to know is

How can I disable the radio button once the user clicks on it

because the update() function changes the values when user clicks on radio button

if he keeps clicking like that then values change each time he clicks

or if he clicks on sibling radio button

so please can anyone tell me how to disable radio button

once user clicks on it

like for instance in match1

if user selects teamA radio button then i want to disable both teamA and teamB radio buttons

same for match2 if he clicks then disable the clciked radio and sibling radio aswell



Thanks for reading this can anyone help me please

I can use plain js, jquery or libraries


More From » jquery

 Answers
7

Use this:



$(:radio).click(function(){
var radioName = $(this).attr(name); //Get radio name
$(:radio[name='+radioName+']).attr(disabled, true); //Disable all with the same name
});


What we're doing, is, when a user clicks a radio button, disable all radios with the same name.



Hope this helps.
Cheers.


[#92397] Tuesday, May 3, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aleighabayleef

Total Points: 511
Total Questions: 99
Total Answers: 99

Location: Aruba
Member since Fri, Jun 24, 2022
2 Years ago
;