ASAP: Help on Font Sizer Control (Funtionality)

I am using the following code in my form (Website/Web page) to control the font size, i.e. to either increment or decrement it.

The code works, however, when I first click on the increment button instead of increasing the font size it decreases it, but this happens ONLY on the FIRST initial click. Afterwards, it works as it should do, i.e. increases the font size.

What I am doing wrong? Any assistance will be much appreciated.

[CODE] (in the JSHeader)

var min=8;

var max=18;

function increaseFontSize() {

var p = document.getElementsByTagName(‘p’);

for(i=0; i<p.length; i++) {

if(p[i].style.fontSize) {

var s = parseInt(p[i].style.fontSize.replace(“px”,“”));

} else {

var s = 12;

}

if(s!=max) {

s += 1;

}

p[i].style.fontSize = s+“px”

}

}

function decreaseFontSize() {

var p = document.getElementsByTagName(‘p’);

for(i=0; i<p.length; i++) {

if(p[i].style.fontSize) {

var s = parseInt(p[i].style.fontSize.replace(“px”,“”));

} else {

var s = 12;

}

if(s!=min) {

s -= 1;

}

p[i].style.fontSize = s+“px”

}

}

[CODE] (on the Web page)

-

+

Thanks in advance.

Nana

Subject: ASAP: Help on Font Sizer Control (Funtionality)

Hello Nana,

the following scenario is causing the problem.

if you take any text like

Sreedhar

definitely that will increase the size. but if you are giving like this

Sreedhar

default it is displaying the text with more than 13px (14,15,16,17…etc). when you click first time default it will take 12 (you have given in the code) + 1=13 . that means 14 goes to 13,15 also goes to 13…etc(decreasing).next time when you click 13+1=14,14+1=15…etc(increasing).

and one more thing the font-size depends on font-family too.

Thanks,

Sreedhar.

Subject: RE: ASAP: Help on Font Sizer Control (Funtionality)

Many many thanks Sreedhar!