Rahul
Rahul

Reputation: 362

javasscript radio button not working?

I am adding attribute for input type radio as checked="checked", in view source it shows but not reflecting in the browser.

edit
<input type="radio" name="status" value="Yes" checked="checked"/>
<input type="radio" name="status" value="No" />

When is check in firebug it shows checked="checked" as shown above, but browser still has no buttons checked.

What might be the cause??

Thanks

Upvotes: 0

Views: 237

Answers (1)

Quentin
Quentin

Reputation: 944564

The checked attribute sets the default checked state, not the current state.

Set the checked DOM property to true or false instead.

document.getElementById('for_example').checked = true;

Upvotes: 3

Related Questions