getElementById('x').value vs. x.value
1.) What is the theoretical/computational/something-to-that-effect difference?
2.) What are the disadvantages/advantages of each version?
y = parseFloat(document.getElementById('x').value);
document.getElementById('x').value = y.toFixed(2);
Assume that "x" is the id of a textbox and that its value is a number. Also, the code above is generalized. My actual code is the same thing with different variables and repeated several times.
y = parseFloat(x.value);
x.value = y.toFixed(2);
(Another note: I want "y" stored for later computation, so it's not completely frivolous.)
Browsers tested: IE 6 and Firefox 2.0 and Opera 9.26.