Hello Everyone,

I am new at this so please bare with me. :)

I've been having such a hard time with my form. I am finally down to one last little problem. I cannot get my font size to display when selected.

This is in my HTML:

<form action="processor.php" method="post">

<p>
<label>Type a font size:</label>
	<input  type="text" value="14" name="font-size"   />

<label>Pick a color: </label> 
<select name="color">
	<option selected="selected" value="yellow">yellow</option>
	<option value="green">green</option>
	<option value="blue">blue</option>
	<option value="orange">orange</option>
	<option value="red">red</option>
</select>

<label>Pick a font Style: </label> 
<select name="font">
	<option selected="selected" value="Comic Sans MS Bold">Comic</option>
	<option value="Script MT Bold">Script </option>
	<option value="Garamond">Garamond</option>
	<option value="Snap ITC">Snap ITC</option>
	<option value="Times New Roman">Times</option>
</select>


<p>
<textarea name="box" cols="70" rows="10">
Please type the text you would like to edit in this box!
</textarea>
</p>


<p>
<input type="submit" value="Submit"/>
<input type="reset" /></p>

***********************************************

This is in my PHP:

<style type="text/css">
   body     { color:        <?php print $_POST["color"] ?>;
	    font-family:	 <?php print $_POST["font"] ?>;
             font-size:     <?php print $_POST["font-size"] ?>
	}
</style>

</head>
<body>

<?php print $_POST["box"] ?>

The color and font-family change when selected but the font-size doesn't change.

Please help.

Thank you

Recommended Answers

All 10 Replies

mmm don't know if this will work but try copying this

<style type="text/css">
body { color: <?php print $_POST["color"] ?>;
font-family: <?php print $_POST["font"] ?>;
font-size: <?php print $_POST["font-size"] ?>;
}
</style>

</head>
<body>

<?php print $_POST["box"] ?>

Hello Zlegend.

Thank you for responding so quickly.
I can't quite see a difference from what I posted to what you responded with.

What exactly are you saying to try????

He says.. nothing but you missed the semicolon (;) at the end of font-size in style part of php page.. By that, may it cause such error... Try it, you would surely get it...

the semi colon shouldn't make a difference since it is the last property being specified. Make sure though that you are specifying the unit of measure for font-size: for example 12px or 12em where px and em are the unit of measure and won't do anything if you don't include it.

all i can think about is to add px to your font size

You want to add pt, not px.

<style type="text/css">
body { color: <?php print $_POST["color"] ?>;
font-family: <?php print $_POST["font"] ?>;
font-size: <?php print $_POST["font-size"] ?>pt;
}
</style>

</head>
<body>

<?php print $_POST["box"] ?>

quoted from http://kyleschaeffer.com/best-practices/css-font-size-em-vs-px-vs-pt-vs/

1. “Ems” (em): The “em” is a scalable unit that is used in web document media. An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc. Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.
2. Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
3. Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.
4. Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.

Hey,

Place the code below in your PHP file and let us know what it displays.

<?php 
echo "Font Size is ".$_POST["font-size"];
die;
?>

Thank you all very much for your speedy response. It is greatly appreciated.


Borzoi: Thank you so much. Your response helped solve my problem.
font-size: <?php print $_POST["font-size"] ?>pt;


Thank you so much.

You are welcome. Remember to mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.