Tuesday, 29 November 2011

Change font size of text in HTML page dynamically using php

Here I am discussing about dynamic changes that can be occur in HTML page.
In desk top applications like Visual Basic , we can easily change the font size of a label by clicking
a button if we programed like so.We does not worry about the background processes.
       But in the case of web the html page to be displayed to the user is send by the server.
The user's browser receives thi page and display it.But the server or php running in it can't make any changes to the page which is already
send.So a program which change the font of a text according to button click is not easily possible in php .But javascript can be used to do this.
      Here I am introducing a different trick in which the font size is send as a parameter in URL to the same page.This is just like in my previous post
 "Varying number of text boxes in HTML form by user".

The code is here :

<?php $n=$_GET["num"]; ?>
<label style="color: BLUE; font-size: <?php echo $n ?>pt">You can Increase or Decrease me</label>

echo "<a href=\"font.php?num=$ni\"><input type=\"button\" value=\"Increase\"> </a>";
echo "<a href=\"font.php?num=$nd\"><input type=\"button\" value=\"Decrease\"> </a>";

A sample screen shot of the resulting page

One thing to be remember is that the name of html page must be "font.php"

You can also read  Pass parameter to another page in PHP
Varying number of text boxes in HTML form  by user in PHP 

Hope that this post is helpful to you.Thanks...

No comments:

Post a Comment

Search This Blog