I have the following in jQuery:
function SelectAccounts() {
if ($("#AccountID option[value='0000']").length > 0) {
$.ajax({
url: "/Administration/Accounts/GetOptions",
data: { ac: $('#AccountID').val()
},
success: function (data) {
$('#AccountID').html(data);
}
});
}
SelectProducts();
}
function SelectProducts() {
if ($("#ProductID option[value='0000']").length > 0) {
$.ajax({
url: "/Administration/Products/GetOptions",
data: { ac: $('#AccountID').val(),
pr: $('#ProductID').val()
},
success: function (data) {
$('#ProductID').html(data);
}
});
}
}
When the account changes I want the product list to change so I put SelectProducts(); at the bottom of that function. However I want it to do an ajax call even if the following is not true if selectProducts() is called from within the selectAccounts() function
$("#ProductID option[value='0000']").length > 0)
Is there an easy way I can do this. I think I’ll have to pass in some parameter to the the seconf function but I am not sure how to do that.
Declare variable:
Change function to accept parameter:
Then when calling the second function do:
Hope that helps.