2
It’s the first time I’ve dealt with this situation, so I don’t know exactly how to get around it. The fact is, I have a form with several inputs, divided by sections:
In Experience Tab, I fill some inputs with the data and when I click on add I create blocks with the data filled in as follows:
$('#'+destino).append(
"<div class='blococurso box-experiencia'>"
+"<label>Empresa:</label> <span class='content' data-content="+experiencia.empresa+">"+experiencia.empresa+"</span><br>"
+"<label>Cargo:</label> <span class='content' data-content="+experiencia.cargo+">"+experiencia.cargo+"</span><br>"
+"<label>Admissão:</label> <span class='content' data-content="+experiencia.admissao+">"+addDemissao.admissao.toString().replace(/,/g, '/')+"</span><br>"
+"<label>Demissão:</label> <span class='content' data-content="+experiencia.demissao+">"+addDemissao.demissao.toString().replace(/,/g, '/')+"</span><br>"
+"<label>Atividades:</label> <span class='content' data-content="+experiencia.atividades+">"+experiencia.atividades+"</span><br>"
+"<i class='fa fa-close btn-fechar fechar-experiencia' data-destino='' data-funcao='remover'></i></div>"
);
By clicking the save data button, I take all the inputs and put in obj javascript, and the data like this from the experience that are in Divs, I get like this:
$("#painel-experiencia .box-experiencia .content").each(function(index){
experiencia.push( $(this).text() );
});
Right now I have an Array similar to that;
.["dasd", "asdas", "01/01/2017", "01/01/2017", "dasdasd", "asdasd", "asdasd", "01/01/2017", "01/01/2017", "asdasdaasd", "asdasda", "asdasd", "01/01/2017", "01/01/2017", "dsadasdas"]
But what I need is more for it:
.[{"empresa": "asdas", "admissao": "01/01/2017", "demissao": "01/01/2017", "atividades":"dasdasd"}, {"empresa": "asdas", "admissao": "01/01/2017", "demissao": "01/01/2017", "atividades":"dasdasd"}]
What I look for is an associative array and a way to add each experience block as an array, within a wrapper array. What I need is more for json, if that’s the only way, how to insert the data into a Json and then wrap it in another json?
If you know any other way to reach the same end it would be very helpful.
The part about filling in inputs works well?
– Sergio
@Sergio , sorry I didn’t understand, fill in the inputs "company, position etc" if yes, the fill is normal, in the image I attached the data that are on the right are data entered by the inputs.
– Rafael Rezende
You tested/understood my answer?
– Sergio