views:

38

answers:

3

I have a radio button something like this,

<input type="radio" value="A" name="NodeLevel" />

When not disabled I could get the value of a pretty easily

using, $("input[name=NodeLevel]").click(function () {},

but when the input type is disabled, how can I get the value of a radio button ?

any work arounds ?

A: 

Have you tried .val()?

$("input[name=NodeLevel]").val()
// returns 'A'

And you can't bind a click event to a disabled element.

KennyTM
no, Could you please help me how to do it ?
Sunil Ramu
@Sunil: Do what?
KennyTM
this is not working for disabled element. Any work arounds?
Sunil Ramu
@Sunil: What do you mean by "not working"? Be specific on what you want to do.
KennyTM
A: 

I think when your form field is disabled you can not access its value. Use some hidden field to contain the same value and read from there.

anand
another option is to make the field readonly instead of disabling it, that way you can read the value but it would be a readonly field.
anand
A: 

As per HTML specification, a form element must be "successful" in order to be sent to the server. Disabled elements are not considered successful (as per the same spec). You can make the element readonly or send it as a hidden form element.

this thread here might shed some light to ur problem

http://stackoverflow.com/questions/524222/how-can-i-get-the-form-value-from-a-disabled-input-element

manraj82