I'm repurposing some code to dynamically add form fields. So I had this:
<input name="projDesc" />
and used the following to create additional fields:
function GetHtml() {
var len = $('.extraProject').length;
var $html = $('.extraProjectTemplate').clone();
$html.find('[name=projDesc]')[0].name="projDesc" + len;
return $html.html();
}
But now I need to switch the input to an array for PHP to process it:
<input name="projDesc[]" />
How do I change the .find method to accommodate this now? Thx.
Followup:
Sorry for the dupe but what are some possible reasons it works in this Fiddle but not on my site? On my site now, I don't even get the initial form field to display.
Also do I need to escape the square brackets in both instances where I mention projDesc?
$html.find('[name=projDesc\\[\\]]')[0].name="projDesc\\[\\]" + len;