Chrome 21 does not check radio buttons

I realized this after a long effort, so I decided to share what I came across, so others can benefit from my efforts. Firefox IE and chrome 19 (the only other version that suits me) don't have a problem with this, but chrome 21 does.

If you have this radio unit

<input type='radio' name'k1' value='v1' checked> 

it will not appear on the page if it is in an invalid place.

For example, I had

 <table> <input type='radio' name'k1' value='v1' checked> <tr><td>table information</td></tr> </table> 

and no matter what I did, it will not appear when the page loads.

+4
source share
3 answers

Tested on Google Chrome 21.0.1180.75 and .79

 <table> <input type="checkbox" name="n" value="v" checked="checked" /> </table> 

The absence of <tr><td></tr></td> around the input element causes the checked flags to not appear as checked. In addition, when submitting a form, these flags are not displayed on the server side as verified!

After the html is formatted correctly, the flags should be checked as indicated by the checked attribute:

 <table> <tr> <td> <input type="checkbox" name="n" value="v" checked="checked" /> </td> </tr> </table> 
+4
source

My html was invalid, but in my case it was hidden, so I did not notice right away, whether hidden or not, the button will not be checked (and therefore not sent with the form) when the page loads.

If you put the input in a valid place, it works fine ...

 <table> <tr><td>table information <input type='radio' name'k1' value='v1' checked> </td></tr> </table> 

So, I had the wrong layout, and I'm sure the popular answer would be โ€œhow could you expect the browser to interpret invalid html?โ€ and I agree, but not checking the switch, especially because it was hidden (and it worked in previous versions of chrome) makes it difficult to track down the error. So I thought I could save someone in a few hours of work.

+2
source

Although this does not apply to the browser in question, some mobile devices (e.g. Galaxy S3) will not check the switch if it is not in shape. Most of the other inputs (e.g. flags, for example) in my experience are beautiful.

0
source

All Articles