I have a global var named inputType
which is a lengthy object:
inputType = {
part1: 'string',
part2: 'string2',
...
part100:'last string'
}
In a separate piece of code, I have some input fields that receive numeric values. I would like to alter certain parts of the var
object string as such:
<input id='input1'>First input
code:
$(document).ready(function(){
$('#input1').blur(function (){
var inp = parseInt($('#input1').val(), 10);
if (inp <10) {
inputType.part2.replace(/string2/,'some other string');
}
});
});
// Then I call this modified inputType.part2 object in another function
// I can't seem to effect the string change when the condition is met? When I try to call this particular object property in another script, the string change is not performed. I also can't see this change on the DOM inspector when I try this out. But this syntax will perform the replace
function when I try it on the console.
How can I replace or modify inputType.part2
when the condition is met, and then use the modified object in another piece of code?
Objects are tough!
Thanks.