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

224
Views
Odoo 14 Change value of input in Javascript

I am calling an api from python that returns json to the javascript function. When returning the data I am setting the value of an input field using jquery. But when saving theform the field value is not being saved. What's the solution? Thanks in advance.

$.each(data['payload'], function(key, val) {
    let el = $('[name='+key+']');
    el.val(val);
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Sometimes websites use form fields only as "frontend" for some internal state that gets synced whenever the data in the field changes.

When a user changes the contents of the field, a change event is fired. This won't happen if you programmatically change the value though, so such a change would not be picked up by code listening for changes.

To fix this problem, you can manually trigger a change event on the field after modifying its value. You seem to be using jQuery, there you can simply use the change() method like this:

el.val(val).change()
           ^^^^^^^^^
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!