OK...I have a function that formats some form input data. When I run the function I save the form object in an array...So far so good.
Now when I am done with my page I want to go back and remove the formatting from the objects. Should be easy since I saved those objects previously, but it appears that what I have is a copy of those objects and not a reference to those objects. So anything I try to update at the end does nothing to the actual object. At least I do not see a change in the DOM. Is there a way to do this without having to crawl all over the DOM to update the values?
[CODE=javascript]{
var arDone = new Array;
function formatCurrency( obj) {
var num = (parseInt(strip Number(obj.valu e) * 100 + .5) / 100).toFixed(2) ;
while(num.match (/\d{4}[\.\,]/)) {
num = num.replace(/(\d+)(\d{3})/, '$1,$2');
}
obj.value = num;
arDone.push(obj );
return num;
}
function cleanCommas() {
var obj;
for (var i = 0; i < arDone.length; i++) {
arDone.value = arDone[i].value.replace(/\,/g, '');
alert(arDone.va lue);
}
alert(document. form1.mortgage1 _balance.value) ;
return 1;
}
}[/CODE]
Now when I am done with my page I want to go back and remove the formatting from the objects. Should be easy since I saved those objects previously, but it appears that what I have is a copy of those objects and not a reference to those objects. So anything I try to update at the end does nothing to the actual object. At least I do not see a change in the DOM. Is there a way to do this without having to crawl all over the DOM to update the values?
[CODE=javascript]{
var arDone = new Array;
function formatCurrency( obj) {
var num = (parseInt(strip Number(obj.valu e) * 100 + .5) / 100).toFixed(2) ;
while(num.match (/\d{4}[\.\,]/)) {
num = num.replace(/(\d+)(\d{3})/, '$1,$2');
}
obj.value = num;
arDone.push(obj );
return num;
}
function cleanCommas() {
var obj;
for (var i = 0; i < arDone.length; i++) {
arDone.value = arDone[i].value.replace(/\,/g, '');
alert(arDone.va lue);
}
alert(document. form1.mortgage1 _balance.value) ;
return 1;
}
}[/CODE]
Comment