Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
Get first or second (class) from parent

I have this kind of code

<form class="row" id="testamentExecutor">

     <div id="executorsSection" class="form-row">

         <div class="executorSection form-row">
             <input type="text" name="firstname">
             ...
             <div class="alternativeExecutorSection visually-hidden">
                 <input type="text" name="firstname">
                 ...
             </div>
         </div>            

     </div>

</form>

Edit, I give more details on the problem

Structure of object

List<Executor> executors;

public class Executor {

    Person executor;
    Person alternative;
}

public class Person {

    String firstname;
    String lastname;
    String city;
}

I read local storage

let testamentExecutorStorage = localStorage.getItem("executorPersons");
let executorTable = JSON.parse(executorStorage);

for(let i=0;i<exectorSize;i++) {
    $("input[name=firstname]").eq(i).val(executorTable[i].executor.firstname);
    $("input[name=lastname]").eq(i).val(executorTable[i].executor.lastname);
    $("input[name=city]").eq(i).val(executorTable[i].executor.city);

    if(executorTable[i].alternative!=undefined){
        $("input[name=firstname]").eq(i+1).val(executorTable[i].alternative.firstname);
        $("input[name=lastname]").eq(i+1).val(executorTable[i].alternative.lastname);
        $("input[name=city]").eq(i+1).val(executorTable[i].alternative.city);
    }
}

It can have 2 block of executorSection alternativeExecutorSection is not mandatorry

Is there a way to get input (alternativeExecutorSection too) of executorSection from array?

alternativeExecutorSection is not visible, my current issue is put visible this section?

example, first executor don't have any value for alternative, so alternativeExecutorSection is hide.

but if second executor have a alternative, how i will see, put it visible in the loop?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

const inputs = document.querySelectorAll(".executorSection input")
inputs.forEach(i => console.log("INPUT VALUE:", i.value))
     <div id="executorsSection" class="form-row">
         <div class="executorSection form-row">
             <input type="text" name="firstname" value="first">
             <div class="alternativeExecutorSection visually-hidden">
                 <input type="text" name="firstname"  value="second">
             </div>
         </div>            
     </div>

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda