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

280
Views
How to place multiple values in another column by selecting one option?

I want to Select one option and auto-fill up the other column.

For example:

| Product Name| Price     |
| ----------- | --------- |
| T-Shirt     | 100       |
| Mobile      | 200       |
| Laptop      | 500       |

Now, i will select Product Name and the price will place automatically. I have looked on this link : https://select2.org/programmatic-control/add-select-clear-items

To be clear please check the image! and Video

Primary Solution by ahmelq:

<form>
       <div class="row">
  <div class="col">
        <select class="form-select" aria-label="Default select example" id="items">
      <option value="" selected hidden disabled>Select an item</option>
      <option value="tshirt-id" data-price="100">T-Shirt</option>
      <option value="mobile-id" data-price="200">Mobile</option>
      <option value="laptop-id" data-price="500">Laptop</option>
  </select>
  </div>
  <div class="col">
    <input type="text" class="form-control" placeholder="Price" aria-label="price" id="priceField" disabled>
  </div>
</div>
       
      </form>
const items = document.getElementById('items');

items.addEventListener('change', function(e) {
  const selectedOptionIdx = e.target.selectedIndex;
  const selectedOption = e.target.options[selectedOptionIdx];
  
  const price = selectedOption.dataset?.price || "This item has no price!";
  
  const priceField = document.getElementById('priceField');
  priceField.value = price;
});
about 4 years ago · Santiago Trujillo
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!