473,473 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How can I automatically Resize the font size using JavaScript?

Exequiel
288 Contributor
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Automaticaly resize the font ? How?</title>
  6. <script type="text/javascript">
  7. function font_size()
  8. {
  9.     var ranger = document.form_name.a.value;
  10.      var p1 = document.getElementById("p1");
  11.       var p3 = document.getElementById("p3");
  12.  
  13.                 p1.innerHTML = ranger + " Ako ay pogi";
  14.                  document.form_name.x.value=ranger;    
  15.                 document.getElementById("p2").style.fontsize= ranger+"px";
  16.                 document.getElementById("p3").style.fontSize="xx-large";
  17. }
  18. </script>
  19. </head>
  20. <body>
  21. <p id="p1"> </p>
  22. <br>
  23. <p id="p2">dfdfdfdfdfdfdf</p>
  24. <p id="p3" >dfgdfgdfgdfgdfgdfgdfg</p>
  25. <br />
  26.  
  27. <form id="numform" name="form_name"  method="post">0
  28.     <input type="range" name="a" max="30" id="rendz" onchange="font_size()"/>
  29.     <input type="text" form="numform" name="x" for="a" style=" width:15px;">
  30. <br>
  31.     <button onchange="font_size()">Button for javascript output</button>
  32.     <input type="submit" name="ok" value="Button for PHP output" />
  33. </form>
  34. <center>
  35. <?php 
  36.     if(isset($_POST['ok'])){
  37.         $range=$_POST['a'];
  38.             echo'the range output : '.$range;
  39. ?>
  40. <br>
  41. <font size=" <?php echo $range; ?>px;">Resize text output for PHP</font>
  42. <?php
  43.         }//end of isset
  44. ?>
  45. <br><br>
  46. </center>
  47. </body>
  48. </html>
My code for automaticaly resize doesn'nt work, can you please help me to fix this problem? please . . . ? :) and thank you. . .
Jul 30 '12 #1
1 2937
Exequiel
288 Contributor
I've got it already. . . here's my code. . . :)
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Automaticaly resize the font ? by zick</title>
  6. <script type="text/javascript">
  7. function font_size()
  8. {
  9.     var ranger = document.form_name.a.value;
  10.       var p3 = document.getElementById("p3");
  11.                  document.form_name.x.value=ranger;    
  12.                 document.getElementById("p3").style.fontSize=ranger+"px";
  13. }
  14. </script>
  15. </head>
  16. <body>
  17. <br>
  18. <br />
  19. <center>
  20. <form id="numform" name="form_name"  method="post">
  21.     Resizer : <input type="range" name="a" max="30" id="rendz" onchange="font_size()"/>
  22.     <input type="text" name="x" style=" width:15px;">
  23. </form>
  24. <br>
  25. <br>
  26. <p id="p3">I am Zick :) </p>
  27. <br><br>
  28. </center>
  29. </body>
  30. </html>
Jul 31 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: wj | last post by:
Hi all, I making a web site where people can change the font size with a form on a seperate page. I store the value in session-variables and read them every time a page is loaded. I wonder if...
2
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
10
by: Luke Duddridge | last post by:
Hello, I work for a local council and have recently been part of the project for a new website design which went live at the end of september at www.tauntondeane.gov.uk. I set the relative...
16
by: JD | last post by:
Hi guys What's the best way to specify font size using CSS? I try to avoid absolute units like pt and px because then users can't resize the fonts in IE, but % and em are a complete pain to use...
1
by: Jesper | last post by:
Hi, When working with high display resolution it's sometimes preferable to increase the general font size using control panel-> display properties-> settings -> advanced -> general -> Display ->...
12
by: newspost2000 | last post by:
http://www.htmldog.com/articles/elasticdesign/demo/ I found this wonderful site the demonstrates how you cannnot resize text formated using styles in ie 6 if you specify font size using pt units...
4
by: gsuns82 | last post by:
hi friends,can any one give the coding for finding file size using java script???
2
by: morgiemorganson | last post by:
Hi, I am sure this will be a 2 second answer but as I am a JS novice I need some help. I am using some buttons on my site to allow users to change the font sizes. It works fine when there is...
58
by: Don Li | last post by:
I've tried <body style="font-family:Verdana,Arial,Helvetica;font-size:0.8em;"> or <body style="font-family:Verdana,Arial,Helvetica;font-size:11pct;"> or <body...
3
Frinavale
by: Frinavale | last post by:
Hi there! I'm hoping that someone knows how to check the size of a file before it is uploaded to the server using JavaScript. I have seen suggested solutions using an ActiveX control to check...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.