tags:

views:

105

answers:

2

hi im new to PHP .. i want a script were i can change the text dynamically when the page is live from (Arial to Times) something like that.. can any one pls help me in dis.. or can anyone pls provide a script for dis..???

+1  A: 
<?php
$font = "courier";

if(isset($_GET['font'])){
    $font = $_GET['font'];
}

?>

<a href="?font=arial">Arial</a> | 
<a href="?font=times">Times</a>

<div style="font-family: <?php echo $font; ?>">
the quick brown fox jumped over a lazy dog.
</div>

... although this might be a job for javascript, in some folks' opinion.

echo
thank u but when i click arial or times its nt working... mean the font is not changing.. wt i should do now.. any modifications .. any sugessiongs pls
Patel
oh weird... it works in firefox for me. you should get the general idea though, right?
echo
thank u very much... this the result i was expecting.. once again thanks for providing such a good script..
Patel
Can u pls explain y ve u mentioned this line $font = "courier"; wts the use of this..
Patel
Easiest 15 rep ever.
Ignacio Vazquez-Abrams
just a default value; if they don't click a font, it defaults to courier.
echo
oh thank u.. then we can set it to any font..
Patel
hi everyone, i want to create a page by using PHP in such a way that page should contains a few color change options and themes by selecting those colors or themes it should refelect in the same page. can anyone pls help me by giving sugessins or proving a script for that..
Patel
A: 

You could also do this with JavaScript

<html>
<head>
    <title>change font test</title>
</head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript">

    $(document).ready(function () {

        $(".changeFontArial").click(function () {
            $("body").css("font-family", "arial");

            return false;
        });
        $(".changeFontTimes").click(function () {
            $("body").css("font-family", "Times New Roman");

            return false;
        });
    });

</script>
<body>
    <p class="changeFontArial">
        Change to Arial</p>
    <p class="changeFontTimes">
        Change to Times</p>
</body>
</html>
Jason Rowe
http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js if u change the path of this then will the script runs normally... and one more can u pls explain brifely y u ve used that line(javascript).. is it so necessary
Patel
I used the JQuery JavaScript library it can be hosted via googleapis as I have shown it.
Jason Rowe
ok thank u.. But Can i implement ur code in a page so that if i clink the ARIAL or Times will the whole content of the page will get change or any modifications i ve to do for that..
Patel
You shouldn't need to change anything.
Jason Rowe
if i ve used few tables in a page and in each <td> there are contnets if i want to change all the <td> contents at a time when i click Arial ro Times then how to implement this script.
Patel
can u pls give the sugessions abt the previous question which i ve asked
Patel
In the above code change $("body").css to $("td").css
Jason Rowe