Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
319 views
in Technique[技术] by (71.8m points)

html - Is it valid to have two input elements with the same name?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, it is valid

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 also fine and will generally be interpreted as an array of values, e.g. {url: [1, 2]}, depending on what your server does. In a URL encoding, it will look like url=1&url=2.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...