Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!