I have a function that is taking in multiple parameters. Using spread operator. But I am stuck in trying to figure out how to concinate the name of each item with a ‘val’ to the end of it. Here is is what I have so far….
//what I am calling
_setReadOrgVals($mfirstname, $mlastname, $mchapname, $mchapnameass, $mnumber, $memail, $mgender, $memailparent, $memailadv, $mffaid);
//the function
function _setReadOrgVals(...$fields) {
for (i = 0; i < $fields.length; i++) {
$fields[i].attr('readonly', true).addClass('bg-black25').val($fields[i] + 'val');
//I want it to feel like I am doing this...
//$mfirstname.attr('readonly', true).addClass('bg-black25').val($mfirstnameval);
//But I don't know how...my example above does not work...
}
}
as a result, my input element outputs…
[object Object]val
Here is an example of first name I am using to go with my code above…
var $mtarget = window.jQuery('.custom-location');
var $mfirstname = $mtarget.find('#pro_fname');
var $mfirstnameval = $mfirstname.val();
So I basically want $mfirstnameval
to be inside of the .val() in my example above. But feel stuck at this point…