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

103
Views
How add [event.target.name] in array selector - next.js app

I have two onChange handlers in my next app, and i would like split this two onChange handlers split in to one. Problem is i really dont know how make right syntax in array selector

// Working solution with two handlers

  const ticketPriceInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].price = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

  const ticketPiecesInreaseHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

    items[index].wave[index2].pieces = e.target.value;

    setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

I try it make one just handler like down on example but i getting always errors..

  const oneHandler = (
    e: { target: HTMLInputElement },
    index: number,
    index2: number
  ) => {
    const items = action.ticketsOnWave;

   items[index].wave[index2].event.taget.name = e.target.value;   // Here is problem 

       setAction({
      ...action,
      ticketsOnWave: [...items],
    });
  };

or i try it

    const nameOfField = e.target.name 

    items[index].wave[index2].nameOfField = e.target.value;   

// here i getting new in object field instead of field name from const nameOfField

What is a right syntax for this ? Thanks

about 4 years ago · Juan Pablo Isaza
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!