javascript name vs ID
javascript, standards, xhtml
Solution
The ultimate guide in this is the HTML specification.
Things that stand out there:
- `id` is valid for any HTML element, while `name` only applies to a select few (`a`, `input`, `textarea` and maybe a few others).
- An `input` (and `textarea`) element requires the `name` to be set if you want it to be submitted.
Problem
As far as I know there are two ways to get the value from a textbox either ``` document.formName.textboxName.value; ``` or ``` document.getElementbyId('textboxId').value; ``` As I understand using form name would mean I have less code to write, as name can be used for posting data and getting the value (apart from using ajax). As where if I was just posting using a standard form I would use `name` to post but I cannot use `id` ? e.g. in php I would use ``` $_POST['texboxName']; ``` If I where to have and ID on the textbox I cannot get the value using php ? Which is the standard recommened way of doing this, and is using `name` browser friendly? Links if possible please, thanks.