|
wilsona5 -> Problem with ParseInt() - JavaScript (2/28/2008 14:44:05)
|
Hey All - I've seem to be having issues with the ParseInt function. In the function below, the styles of two different CSS DIVS (parameters 'd' and 'e') are being affected. Parameter f is a number value (which is ultimately supposed to be added to the original height value of one of the DIVS - being passed through parameter 'e'). In the function, if I manually set 'OldHeight' to a number value, such as 1700, the function will complete without errors. However, 'OldHeight' is supposed to gather and store the original value of the CSS DIV (which 'f' is then added to). I assume that the CSS style height value is stored as a string, so I've tried using the ParseInt in order to change the value to a number, so the values are added together, instead of being concatenated. When this format is used, errors are received referencing an 'Invalid Argument.' Does anybody know what I might be doing incorrectly? Thanks a ton! function ShowContent(d,e,f) { var LeftName = String(e); var AddValue = parseInt(f); var OldHeight = parseInt(document.getElementById(LeftName).style.height); var stringOldHeight = document.getElementById(LeftName).style.height; document.getElementById(d).style.display = "block"; document.getElementById(LeftName).style.height = AddValue + OldHeight; } - Andrew
|
|
|
|