3
I’m using the plugin of jquery.cloneya
which is a plugin to clone forms that were already included in a template of an administrative panel I’m using. I don’t quite understand how to use the hook that plugin to increase the name of a input every time he’s cloned.
For example: I click on the "+" sign and clone one or two fields together. These two fields have their name augmented this way > "name='produtos[qtd][2]'
", being the index of the first input started with "[qtd][0]
".
I asked the developer of plugin if it was possible to clone and increase Names and he answered me the following:
"Yes, it is. Ideally, due to the Nature of cloned form Elements, the Names should be name[], so that the values can be processed as arrays. If you need to increment name and/or value, you can plug into the custom Event - clone_form_input
.
See: https://github.com/yapapaya/jquery-cloneya/blob/master/jquery-cloneya.js#L119.
Your question is not very clear to me. Is your question how to clone and add [Qtd][] ?? How is your code today?
– Igor Martins
yes, let’s say you have a form, and want to clone a
<select>
and a text input, and every time you create a clone of these two elements, you want to increment +1 to the input name, if I have an input "products[Qtd][]" = products=>quantity=>(input ID array). it should stay products[Qtd][1], products[Qtd][2]... whenever a new clone is created.– Leandro RR
your question has not been answered here? http://answall.com/questions/9548/comorclonar-um-elemento-com-jquery-e-addir-um-newname
– Igor Martins
no, this question is not related to this plugin. actually, it was answered but without the use of the plugin, now need using the plugin.
– Leandro RR
How not? It’s there... Jquery Cloneya
– Igor Martins
yes, but the subject answered with pure js. this question is reserved to the plugin.
– Leandro RR