I'm trying to bind values to three different textboxes on corresponding testbox keydown event but it is just working for one textbox. I'm sharing my code please guide me with solution
HTML:
<table>
<tr>
<td>
<input type="text" id="BuyingPrice0" value="10" style="width:55px;" />
</td>
<td>
<input type="text" id="bpusd0" readonly value="1.22" style="width:50px;" />
</td>
</tr>
<tr>
<td>
<input type="text" id="BuyingPrice1" value="10" style="width:55px;" />
</td>
<td>
<input type="text" id="bpusd1" readonly value="1.22" style="width:50px;" />
</td>
</tr>
<tr>
<td>
<input type="text" id="BuyingPrice2" value="10" style="width:55px;" />
</td>
<td>
<input type="text" id="bpusd2" readonly value="1.22" style="width:50px;" />
</td>
</tr>
</table>
JQUERY:
var BindBP = function (id, BPUSD) {
var errormsg = "";
var amount = $(id).val();
var country21 = $('#CurrencyValue').val();
$.ajax({
type: "GET",
url: cc,
data: { amount: amount, country: country21 },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$(BPUSD).val(data);
},
error: function (jqXHR, exception) {
}
});
}
$(document).ready(function () {
var count = 3;
window.count = 0;
var bp2 = $("#BuyingPrice" + window.count);
var converted2 = $("#bpusd" + window.count);
$(bp2).on("keydown", function () {
for (var i = count; i <= count - window.count; i++) {
var bp = $("#BuyingPrice" + i);
var converted = $("#bpusd" + i);
BindBP(bp, converted);
}
});
});
i want to change value of bpusd checkboxes on corresponding buying price changed value but now it when i type in BuyingPrice of any id it is only getting BuyingPrice0 value. Please guide me the perfect way of doing this