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)

1
  • 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.... Commented Sep 11, 2016 at 20:28

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Yes I've that on my form <select id="wateres" onchange="wrForm(this.value)">
So you have your answer... When you run .change() it triggers onchange="wrForm(this.value)" and it runs that function. Glad that it help you.
Maybe this will help. stackoverflow.com/questions/13343566/… .. Just use yourID val your value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.