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

249
Views
obtener un valor de atributo de datos (teléfono de datos) de la opción de lista de datos seleccionada

cómo obtener un valor de atributo de datos (como: - teléfono de datos) de la opción de lista de datos seleccionada que está seleccionada; Me envía solo valor, no atributo de datos.

Quiero configurar el teléfono de datos de la entrada desde el teléfono de datos de la lista de datos> opción

¿Cómo puedo configurar esto? Ayuda

HTML:

 <input type="text" name="patirnt_name" id="patirnt_name" list="patient_list" onfocus="getAllPatients()" value="" data-phone=""> <datalist id="patient_list"> </datalist>

JQuery:

 function getAllPatients() { let url = "{{ route('get-all-patient-ajax') }}"; let list = $('#patient_list'); let html = ''; $.ajax({ url: url, type: "GET", success: function(res) { let data = res.patients; $.each(data, function(index, value) { html += `<option value="${value.F_name}" data-phone="${value.phone}" >${value.F_name}</option >`; }); list.html(html); }, error: function(error) { console.log(error); } }) }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Según tengo entendido, cuando list.html(html) todas las opciones se muestran en el DOM sin el data-phone="${value.phone}" que configuró en each bucle. Podrías intentar esto:

 $.each(data, function(index, value) { $('<option/>', { value : value.F_name, data-phone : value.phone }).text(value.F_name).appendTo(list); });
about 4 years ago · Juan Pablo Isaza 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!