简体   繁体   中英

How can I do this when I clicked button with data it will selected value on select option data with NextJS?

Hello I am beginner with NextJS how can I do when I click button it will selected values on select option data like example with this link https://www.mobicom.mn/mn/shop/newnumber#/ after click first 4 digit below select options it will change on select option above how can I do this and fetch data next to first 4 digits? This is buttons with data

This is select option tags

When i click 7801 button it will get 78 01 on select option?

I'm assuming you trying to work out how to get data and handle states

const App = () =>{
  const [state,setState] = useState();

  return (
    <select onChange={(e) => setState(e.currentTarget.value)} value={state}>
      <option value="1">Value 1 </option>
      <option value="2">Value 2</option>
      <option value="2">Value 3</option>
    </select>
  )
}

This is a very basic example, we use the "onChange" on the select to get its currectly selected value, once you "change" it it will set the state to the value eg setState('some value here') changes the value of state

This is buttons with data

This is select option

When i click 7801 button it will get 78 01 on select option?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM