views:

41

answers:

4

i.e.:

<form 1>
<input type="hidden" name="url" value="1">
</form 1>

and

<form 2>
<input type="hidden" name="url" value="2">
</form 2>

Is this allowed and valid?

A: 

Yes.

More, it is essential if you are dealing with radio button groups.

David Dorward
Exactly. Or with checkboxes, in which case you can put [] at the end "url[]" and it creates an array to be picked up.
Kerry
@Kerry — That's a PHPism. Most form handling libraries are quite happy to not have special names for groups of controls.
David Dorward
Ah, good to know.
Kerry
+2  A: 

Yes -- each will only submit with their respective forms.

If you have them in the same form, one will override the other and it is not valid.

Kerry
Thanks :)15char.
Rohan
+3  A: 

Yes, in your case, it is valid. Consider this:

This is Good

<form name="form1">
  <input type="hidden" name="url" value="1">
</form>

<form name="form2">
  <input type="hidden" name="url" value="2">
</form>

This is Not Good

<form name="form1">
  <input type="hidden" name="url" value="1">
  <input type="hidden" name="url" value="2">
</form>
Web Logic
why the down vote?
Web Logic
It is valid. It will create no confusion for the server side language (even PHP, with its conventions for naming fields that share a name, will consistently and predictably handle multiple inputs which don't use that convention). It will create no confusion for JavaScript (which will present the elements as a collection and **not** ignore one of them). It /might/ create confusion for authors who write code without knowing what they are doing, but it is fine by the spec.
David Dorward
@David Dorward: Thanks for explaining that, I removed that part.
Web Logic
+1  A: 

To test if it is valid or not, creat you page and test at W3C here :

http://validator.w3.org/

dotNET