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

108
Views
Tener 2 valores diferentes en un menú desplegable <opción>

Tengo este menú desplegable en codeigniter Nama Barang . Este es el código:

 <div class="form-group"> <label>Nama Barang</label> <div class="form-inline"> <select id="nama" class="form-control namabarangsearch col-sm-10" name="name" required onchange="getNamaTransaksi()"> <option value="">-- Nama Barang --</option> <?php foreach ($groups as $group) { echo '<option value="' . $group->stok. '" value="' . $group->name . '">' . $group->name . '. Stok : ' . $group->stok . '</option>'; } ?> </select> </div> <small class="form-text text-muted" id="sisa"></small> </div>

Luego el guión:

 <script> function getNamaTransaksi() { var x = document.getElementById("nama").value; document.getElementById("sisa").innerHTML = "Nama barang : " + x; } </script>

¿Qué debo hacer si quiero tener 2 valores de la opción, para poder llamarlo en el script? He intentado hacer esto:

 <script> function getNamaTransaksi() { var x = document.getElementById("nama").value['$group->stok']; document.getElementById("sisa").innerHTML = "Nama barang : " + x; } </script>

Pero me da un valor indefinido. ¿Qué estoy haciendo mal aquí? También lo siento si mi código está desordenado.

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!