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

197
Views
How to add multiple variables in .val() jquery function

I am adding data using AJAX then appending that data in dropdown, after that I am using .val().trigger() jQuery function to get that newly added data on the top of drop down by passing multiple variables in .val() function; val function is accepting one variable and working fine but I want to add multiple variables in val() function.

JS CODE

success: function(data) {
  toastr['success']("<?php echo lang('add'); ?>", "Customer Device Added");
  setTimeout(function() {
    const obj = JSON.parse(data);
    // console.log(data)
    // console.log(obj)
    jQuery('#customer_device').append('<option value="' + obj[0].device_brand + ' ' + obj[0].device_model + ' ' + obj[0].device_imei + '">' + obj[0].device_brand + ' ' + obj[0].device_model + ' ' + obj[0].device_imei + '</option>');
    jQuery('#customer_device').val(obj[0].device_brand).trigger("change");
    $('#customer_device_modal').modal('hide');
  }, 500);
}

Here I am appending these data:

obj[0].device_brand, obj[0].device_model, obj[0].device_imei

I want to trigger these all variables in .val() function to get these in dropdown at top; as I am getting one variable in val function. Thank you

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!