<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2015-10-09 16:12 GMT-05:00 Christian Huldt <span dir="ltr"><<a href="mailto:christian@solvare.se" target="_blank">christian@solvare.se</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">To me, that seems to be able to add several tags with the same id - I<br>
think that is harmful...<br>
<div class="HOEnZb"><div class="h5"><br>
Den 2015-10-09 kl. 23:02, skrev Richard Reina:<br>
> I have a input tag in a form:<br>
><br>
> <div class="col-xs-4 col-md-4"><br>
>         <div id="p_scents"><br>
>           <p><br>
>               <label for="p_scnts"><input type="text" id="p_scnt" size="20" name="p_scnt" value="" placeholder="email address" /></label><br>
>           </p><br>
>         </div><br>
>       </div><br>
><br>
><br>
> Which gets it's name from the JS function below. However, that name I can't figure out. I have tried<br>
> p_scnt_1 but it comes back undefined. Any ideas what the param name would be for each sequentially added item?<br>
> Here's a working example of the form: <a href="http://jsfiddle.net/jaredwilli/tzpg4/4/" rel="noreferrer" target="_blank">http://jsfiddle.net/jaredwilli/tzpg4/4/</a><br>
><br>
><br>
> $(function() {<br>
>         var scntDiv = $('#p_scents');<br>
>         var i = $('#p_scents p').size() + 1;<br>
><br>
>         $('#addScnt').live('click', function() {<br>
>                 $('<p><label for="p_scnts"><input type="text" id="p_scnt" size="20" name="p_scnt_' + i +'" value="" placeholder="Input Value" /></label> <a href="#" id="remScnt">Remove</a></p>').appendTo(scntDiv);<br>
>                 i++;<br>
>                 return false;<br>
>         });<br>
><br>
>         $('#remScnt').live('click', function() {<br>
>                 if( i > 2 ) {<br>
>                         $(this).parents('p').remove();<br>
>                         i--;<br>
>                 }<br>
>                 return false;<br>
>         });<br>
> });<br>
<br>
</div></div></blockquote><div><br></div><div>I don't think it adds the tags with the same name because when I test the params the first p_scnt comes through as the first value added. If the tags were being added with the same name I would think that either 1) they would be string with both values or 2) the last input would override the previous input. Since param('p_scnt') equals the first value entered neither of those outcomes are occurring.  <br></div></div></div></div>