Is it an acceptable practice to have multiple HTML forms on a page with input fields that share the same name attribute? For example, the page contains a listing of all players and users are allowed to vote for the best player so next to each player card there is this form:
<form class="vote-for-player" enctype="application/x-www-form-urlencoded" method="post" action="/index/vote-for-best-player">
<input type="hidden" name="player_id" value="1" />
<input type="submit" name="vote_for_player" value="Vote" class="input-submit" />
</form>
Value attribute of the hidden input field is different for each form, of course.
Let's say there are 20 forms like this on the page so that means 20 input fields with the name equal to "player_id". If I pass that page through HTML validator, it is valid even with the XHTML 1.0 Strict doctype. But is this an acceptable practice from web standards or accessibility perspective?
One thing I know for sure, it makes the server side processing of the page easier as I just need to load value from one POST field called player_id.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…