One types the number of Inputs they want and click GO, it creates that many number of input fields. How do I make it so each will have their own unique name?
I want to have unique names for each input created so ie:
- 1st Inputs: name="productcode1"
name="desc1" name="dollars1" name="cents1" 2nd Inputs: name="productcode2"
name="desc2" name="dollars2" name="cents2"$(document).ready(function(){ $('#addButton').click(function(){ var count = parseInt($('#quantity').val()); var newHTML = []; for(var i=0;i<count;i++){ newHTML.push('Product Code: <input name="productcode[]" type="text"/> Description: <input name="desc[]" type="text"/> $<input width="100px" type="text" name="dollars[]" size="5" maxlength="6"/>.<input width="50px" type="text" name="cents[]" size="1" maxlength="2"/><br/>'); } $('#sandbox').html(newHTML.join('')); }); });
FYI I'm also using PhP if it is easier to be incorporated