I'm trying to dynamically add a parameter
to the array object url
based on a function's value.
Unfortunately, my attempts so far have been unsuccessful.
var change_lookup_number = function() {
var type = document.getElementById('type_number').value;
if (type == 1) {
//url should be "/hello/lookup/modelname.js?columns[column_id]=1"
} else if (type == 2) {
//url should be "/hello/lookup/modelname.js?columns[column_id]=2"
} else {
//url should be "/hello/lookup/modelname.js?columns[column_id]=6"
}
};
change_lookup_number();
var sections = [
{
url: "",
}
]
(function(){
$.each(pcdfs, function(i, section) {
console.log(section.url); // It's empty, I want to change this section.url
}
})();
Any help or suggestions would be greatly appreciated!