Any way for PHP to get id of a textbox or select in a form?

Of course when you have a form input like <input type=“text” id=“1” name=“city” value=“”>, PHP gets the name and value from a $_POST var, but what about the id? Is that even passed to the PHP $_POST values or is more of something that has to be manipulated with JavaScript?

Of course an id MUST start with a letter so all these examples using numbers are completely invalid.

Confused with DOM’s ID property and City ID?

Good point, forgot about that.

This does beg the question, why do you even need to pass the ID? A name/value pair should be enough.

It is not passed. You would need JavaScript to do something to allow it to be sent, e.g. create an <input type=“hidden”> element with the data you want to pass on.

The easies thing, of course, is to simply include it in the value. If the value was “Moscow”, you can turn it into “Moscow_346215” and then use PHP to split that into the city name and the ID.