0

I have used the while loop to populate the textbox component using onchange jquery function. but i am unable to return the value 5 for each 5 component using jquery.

$(document).ready(function () {
    $('#fname').change(function () {
        var tot_row = 5;
        var row = 0;

        while (row < tot_row) {
            var math_marks = eval('get_math_marks_' + row + '_value()');
            var eng_marks = eval('get_eng_marks_' + row + '_value()');
            var variance_marks = math_marks - eng_marks;

            var component_to_be_replaced = 'variance_' + row;

            $("#component_to_be_replaced").val("5");
            row++;
        }
    });
});

I have been using the iframe.

1
  • I wish I can do a message.toLowercase() Commented Nov 21, 2013 at 21:44

1 Answer 1

1

Change:

$("#component_to_be_replaced").val("5");

to

$("#" + component_to_be_replaced).val("5");

It shouldn't be a string literal.

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

Comments

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.