0
I have a div
(users' mosaic) that within it has a array
(javascript) with photos of users(data coming from the database). The amount of photos of users must be less than or equal to 15. If the array
has less than 15 users(photos), must be filled with an icon or image representing that is without user.
Can someone help me?
Below is an example:
html += '<div class="mosaico-user wrap">'
+ '<div class="liderGrupo"></div>';
var iconePadrao = '<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>';
var demoParticipantes = ['<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste1.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/4.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste1.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/4.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste1.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/teste.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover" data-original-title="" title=""><img src="/resources/img/4.jpg" class="fotousuario"></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x usuarioSemFoto" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x usuarioSemFoto" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x usuarioSemFoto" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x usuarioSemFoto" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>',
'<a class="linkUsuario" rel="popover" href="#" data-popover-content="#infoUser" data-toggle="popover"><i class="fa fa-user fa-3x semUsuario" aria-hidden="true"></i></a>'
];
var conteudo = "";
var i;
for (i = 0; i < 15; i++) {
conteudo = demoParticipantes[i];
html += conteudo;
}
Sure! If you provide some code, preferably HTML and javascript.
– BrTkCa
Sorry. I added an example to facilitate.
– André Albson
I swear that by default I have been codando and created a good answer, but stopped to read again your question and looked at my answer. This is such a basic/easy thing, it feels like you didn’t even try to do it and have already come to you for help. Please show what you’ve done and what’s not working that we’ll help you, give the answer so right away does not roll here at Stackoverflow, just paying the time $$.
– Giovane
Show, now it’s just up to you to validate if your array has 15 elements, if not, you enter the icon value in the array and dps iterates and fills the content.
– Giovane
face poe o Cod seu q pulls from db and etc he much easier in my opinion you deal in the language that pulls from db the amount of items in the array
– Jasar Orion
Guys, easy or hard is a valid question. OP provided the code, if a similar question has already been answered only mark as duplicate, otherwise stackoverflowers are here to help. I think you can post your solution @Giovane =]
– BrTkCa
@Lucascosta opened the question and saw without code and hit me that feeling of GUJ with the crowd wanting the job done and effortlessly.
– Giovane
I understand you @Giovane, but it was not effortless. I tried a few ways here but I didn’t get the result I wanted. I initially posted the question, but forgot to insert a code exemplifying my attempt.
– André Albson