1

I have a fiunction that set value to form field from Object and during execution another uncalled function start and I do not why....

function loadRecord(i) {// Function for display records which are retrived from database.
    var item = dataset.item(i);
    $("#data_id").val((item['id']).toString());
    $("#source").val((item['source']).toString());
    $("#s_date").val((item['s_date']).toString());
    $("#lat").val((item['lat']).toString());
    $("#lon").val((item['lon']).toString());
    $("#acc").val((item['acc']).toString());
    $("#image").attr("src", item['photo']);
    $("#photo").val((item['photo']).toString());
    $("#exif").val((item['exif']).toString());
>>>>$("#wateres").val((item['wateres']).toString()).change(); //the other function sart here!
    $("#top").val((item['top']).toString()).change();
    $("#pump").val((item['pump']).toString()).change();
    ..... the function continue normally

The form fields are identified by $("input_id") the only difference in the row that cause the unwanted behaviour is that is the first select of the form. But if I comment this row everything work well and the next row (is a select to)

  • The other function is probably called by a click event handler, which could be bound by HTML `onchange` attribute, or a jQuery `$("#top").change(...)` call, or many other variants of how events can be listened to. Without more information we cannot know.... – trincot Sep 11 '16 at 20:28

1 Answers1

1

Maybe you define some event on that item?

Like

$("#wateres").on("change", function(e){}); 

Because when you apply change() it Bind an event handler to the "change" JavaScript event, or trigger that event on an element.

From docs https://api.jquery.com/change/

So check your code for that listener.

Hope this helps.

Mykola Borysyuk
  • 3,373
  • 1
  • 18
  • 24