User974100899 posted
I am taking a JavaScript course at my local trade school to get better at it. This is an intro course....and we have been passing data from JS to our Controller like this
for (i = 0; i <= AddCount; i++) {
var saveInfo = {
Address: $("#streetAddress" + i).val(),
City: $("#City" + i).val()
};
saveData(saveInfo);
now our bonus for the week is to translate this example into the above syntax....
$(this).find("td").each(function() {
if($(this).has('input[type="checkbox"]').length>0){
if($(this).find('input').is(':checked')) {
beenVerified ='on';
}else{
beenVerified ='off';
}
}
});
if($(this).has('input.streetAddress').length>0){
streetAddress = $(this).find('input.streetAddress').val();
}
update(streetAddress, beenVerified);
My thought is to code it just like this but I"m not sure if I fully understand....
var saveInfo = { beenVerified: beenVerified, streetAddress: streetAddress };
update(saveInfo);
Does this look right to people more versed in JavaScript?
I think what needs to be done is to not pass in individual variables, but to pass in an array that contains all the variables. Which is why I did it the way I did in the 3rd code sample....