PDA

View Full Version : Changing button font size



TarkaDahl
Sep 12th, 2007, 02:20 PM
Hi all,

ive been trying to edit a buttons font size onchanging a drop down menu

below is my javascript code

<script language='javascript' type='text/javascript'>

function ChangeFontSize(box){

document.forms[0].DisplayB.style.font = box.value +"px";
document.forms[0].Back_Color.value = box.value +"px";
}
</script>



<select size="1" onChange='javascript: ChangeFontSize(this)' name="D2">
<option value="8" selected>8</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="51">51</option>
</select>



<input type="button" value="000.00.00.00.000" name="DisplayB" style="height:60;width:120;border:none;font-size:51;font-family:Times New Roman;"></p>



i dont know if its possible. if not. is there another way of doing something similar.

Thanks

Fang
Sep 12th, 2007, 02:30 PM
document.forms[0].DisplayB.style.fontSize=

<input type="button" value="000.00.00.00.000" name="DisplayB" style="height:60px;width:120px;border:none;font-size:51px;font-family:'Times New Roman';"></p>

TarkaDahl
Sep 12th, 2007, 02:38 PM
Hi Fang

Thanks for quick reply

i changed it to


<script language='javascript' type='text/javascript'>

function ChangeFontSize(box){

document.forms[0].DisplayB.style.FontSize = box.value +"px";
}
</script>


<select size="1" onChange='javascript: ChangeFontSize(this)' name="D2">
<option value="8" selected>8</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="51">51</option>
</select>

<input type="button" value="000.00.00.00.000" name="DisplayB" style="height:60px;width:120px;border:none;font-size:51px;font-family:Times New Roman;">


but it does not change the font size
ive also tried


document.forms[0].DisplayB.style.font-size = box.value +"px";
document.forms[0].DisplayB.style.fontsize = box.value;
document.forms[0].DisplayB.style.font-size = box.value;

which was suggested on a website but i just get error on page
mabe im doing something wrong

Thanks

Fang
Sep 12th, 2007, 04:07 PM
You tried all variations except the one I gave:
<script type='text/javascript'>

function ChangeFontSize(box){

document.forms[0].DisplayB.style.fontSize = box.value +"px";
}
</script>
'Times New Roman' also quoted
<select size="1" onchange='ChangeFontSize(this);' name="D2">
<option value="8" selected>8</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="51">51</option>
</select>

<input type="button" value="000.00.00.00.000" name="DisplayB" style="height:60px;width:120px;border:none;font-size:51px;font-family:'Times New Roman';">

TarkaDahl
Sep 12th, 2007, 04:49 PM
hi Fang

it does work :thumbsup: :thumbsup: - when i type it correctly

Thanks

TarkaDahl

P.s i found a good website at http://msconline.maconstate.edu/Tutorials/JSDHTML/JSDHTML10/jsdhtml10-01.htm