I try to have unique names to cloned checkboxes, and instead of getting, let's say:
Origin_1, Origin_2, Origin_3, for cloned 1, 2, 3 of the same element,
I get:
Origin_1, Orignin_11, Origin_111
I understand the issue: the clone, uses the past clone as origin name. I do not know what should be the approach to go around. Either finding a way to use the very original name, or trim by one character the name of the previous clone and make sure the counter does not start at the begining again. Your hints will be appreciated.
Here is the javascript code:
$(window).load(function() {
var bindFunction = $('#quickmenuall input:checkbox').change(function(){
var uniqueId = 1;
var currentName = $(this).attr('name');
newName = currentName + (uniqueId++);
if($(this).is(':checked')){
var clonedClient = $(this).parent().parent().parent().parent().parent().clone(true)
var ori = $(this).parent().parent().parent().parent().parent()
clonedClient.insertBefore(ori)
$(this).attr('name', newName)
var clonedClient = $(this);
$(this).prop('checked', false)
} else {
var clonedClient = $(this);
clonedClient.parent().parent().parent().parent().parent().remove()
checkbox.bind("change", bindFunction);
bindFunction();
}
});
});
Here is a jsfiddle : http://jsfiddle.net/Sergelie/ULywc/