The code you wrote does exactly what you asked it to do: when the user clicks on the element, the function is run.
There are two ways you can change it to get your desired efect:
- Use another event instead of onclick
- Stop the function execution
Another event
You might want to look towards the CHANGE event (https://developer.mozilla.org/en-US/docs/Web/Reference/Events/change)
Stop function
Inside the function you can check the state of your RadioButtonList. If it is disabled, you simply return;
from the function instead of running the actual useful code. If you don't want to alter the original function, you can write a small wrapper that calls it only if the RadioButtonList is enabled and use the wrapper as handler for the 'click' event.