Hacker News new | past | comments | ask | show | jobs | submit login

Once a website reaches a certain scale you better have a backend that generates your forms already.

Since input elements already have unique names/values, otherwise the backend wouldn't know what you've posted. You can use a (scrambled) version of this, plus a sequence number if required in case of multiple inputs with same name.

Remembering to manually insert the label for every radio input is just bound to fail.




On a large-scale rich webapp, input elements don't have to have unique names, because you're not posting forms directly to the backend.

Instead, you identify your input elements with classes, use something like jQuery to read the values from elements with certain classes from inside a specific DOM element only (not globally), and then POST to the server using AJAX. Nowadays, user interface elements have no need to be tightly coupled with HTTP parameters.

ID's worked in the era of non-JavaScript. But for large dynamic sites where JavaScript is required (webapps, etc.), I haven't used ID's anywhere for years, thank God (like I said, an antipattern).


Just treat labels like remembering the closing tag of any html element.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: