How can I automatically Resize the font size using JavaScript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #1

    How can I automatically Resize the font size using JavaScript?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Automaticaly resize the font ? How?</title>
    <script type="text/javascript">
    function font_size()
    {
    	var ranger = document.form_name.a.value;
    	 var p1 = document.getElementById("p1");
    	  var p3 = document.getElementById("p3");
    	 				
    				p1.innerHTML = ranger + " Ako ay pogi";
    			 	document.form_name.x.value=ranger;	
    				document.getElementById("p2").style.fontsize= ranger+"px";
    				document.getElementById("p3").style.fontSize="xx-large";
    }
    </script>
    </head>
    <body>
    <p id="p1"> </p>
    <br>
    <p id="p2">dfdfdfdfdfdfdf</p>
    <p id="p3" >dfgdfgdfgdfgdfgdfgdfg</p>
    <br />
    
    <form id="numform" name="form_name"  method="post">0
    	<input type="range" name="a" max="30" id="rendz" onchange="font_size()"/>
    	<input type="text" form="numform" name="x" for="a" style=" width:15px;">
    <br>
    	<button onchange="font_size()">Button for javascript output</button>
    	<input type="submit" name="ok" value="Button for PHP output" />
    </form>
    <center>
    <?php 
    	if(isset($_POST['ok'])){
    		$range=$_POST['a'];
    			echo'the range output : '.$range;
    ?>
    <br>
    <font size=" <?php echo $range; ?>px;">Resize text output for PHP</font>
    <?php
    		}//end of isset
    ?>
    <br><br>
    </center>
    </body>
    </html>
    My code for automaticaly resize doesn'nt work, can you please help me to fix this problem? please . . . ? :) and thank you. . .
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #2
    I've got it already. . . here's my code. . . :)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Automaticaly resize the font ? by zick</title>
    <script type="text/javascript">
    function font_size()
    {
    	var ranger = document.form_name.a.value;
    	  var p3 = document.getElementById("p3");
    			 	document.form_name.x.value=ranger;	
    				document.getElementById("p3").style.fontSize=ranger+"px";
    }
    </script>
    </head>
    <body>
    <br>
    <br />
    <center>
    <form id="numform" name="form_name"  method="post">
    	Resizer : <input type="range" name="a" max="30" id="rendz" onchange="font_size()"/>
    	<input type="text" name="x" style=" width:15px;">
    </form>
    <br>
    <br>
    <p id="p3">I am Zick :) </p>
    <br><br>
    </center>
    </body>
    </html>

    Comment

    Working...