I know that there is a lot of topics regarding this question, but believe me, I read all of them and none worked with me :/
Btw I use laravel-4
My form:
<div id="input1" style="margin-bottom:4px;" class="clonedInput">
Name: <input type="text" name="name1" id="name1" />
</div>
<div>
<input type="button" id="btnAdd" value="add another name" />
<input type="button" id="btnDel" value="remove name" />
</div>
My Js:
('#btnAdd').click(function() {
var num = $('.clonedInput').length;
var newNum = new Number(num + 1);
var newElem = $('#input' + num).clone().attr('id', 'input' + newNum);
newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum);
$('#input' + num).after(newElem);
$('#btnDel').attr('disabled','');
if (newNum == 5)
$('#btnAdd').attr('disabled','disabled');
});
$('#btnDel').click(function() {
var num = $('.clonedInput').length;
$('#input' + num).remove();
$('#btnAdd').attr('disabled','');
if (num-1 == 1)
$('#btnDel').attr('disabled','disabled');
});
$('#btnDel').attr('disabled','disabled');
And on my controller: (just to check if is there anything on the var)
$child = Input::get('name2');
return $child;
As you can see, I'm trying to return the second name only, cause the first works (cause its static, not generated by the jquery)
My question is, is there anything wrong? How can I retrieve the value from the other generated fields (up to 5) (name1 works fine[cuz static], name2,name3,name4,name5)?
Thanks in Advance, I've a whole back-end waiting for me :/.
Help me StackOverflow, you are my only hope (got the quote?) haha ;)
http://pastebin.com/VpWq0x43 (my whole view / form page)