PDA

View Full Version : Form Option Select Values



redrubi
03-02-2008, 05:48 PM
Can some one tell me how to change my form selction from text to an Image.

Current selections for example"

$fontnames = array(
'Ac.ttf' => 'AC',
'aftermat.ttf' => 'Aftermath',
'airmole.ttf' => 'Airmole',
'airmolea.ttf' => 'Airmole Antique',
'AlbertText-Bold.ttf' => 'Albert Text Bold',

I would like to replace the text "AC", "Aftermath", etc.. with an image (.gif) of the font syle.

boogyman
03-03-2008, 01:57 PM
go into an image editing software program like fireworks / gimp / photoshop / paintshop pro and create one, then save it as the gif and upload all of the text images to their own separate folder and assign the url to the array you built there

Please review our Posting Policies (http://www.dynamicdrive.com/forums/showthread.php?t=24866) especially in regards to #8 posting computer code

redrubi
03-04-2008, 03:40 AM
How do I assign a URL to the array. Do you have an example of some code for this by chance?

Thanks

alexjewell
03-04-2008, 03:52 PM
'aftermat.ttf' => 'aftermath.gif'

Just replace the text with the image, then wrap it with the image tag when you echo it.

redrubi
03-04-2008, 06:01 PM
'aftermat.ttf' => 'aftermath.gif'

then wrap it with the image tag when you echo it.

You lost me on this part.. Can you provide an example on wrapping an image tag and echoing it?

redrubi
03-06-2008, 12:16 AM
You lost me on this part.. Can you provide an example on wrapping an image tag and echoing it?


Anyone?????

Master_script_maker
03-06-2008, 01:21 AM
please show us the whole code so we can better help you

redrubi
03-08-2008, 09:56 PM
<?php

//Font Previewer



$fontdir = '/fonts';

// The list of font filenames, together with their names.
// Use the format provided here in the example.
$fontnames = array (

'Ac.ttf' => 'AC',
'aftermat.ttf' => 'Aftermath',
'airmole.ttf' => 'Airmole',
'AlbertText-Bold.ttf' => 'Albert Text Bold',
'amsterdam.ttf' => 'Amsterdam',
'ANGLEPOI.TTF' => 'Anglepoise Lampshade',
'ANKLEPAN.TTF' => 'Ankle Pan',
'ArgosGeorge.ttf' => 'Argos George',
'arialbd.ttf' => 'Arial Bold',
'astronbo.ttf' => 'Astron Boy',
'Becker.ttf' => 'Becker',
'Bloody.ttf' => 'Bloody',
'CURLZ.TTF' => 'Curlz',
'darkside.ttf' => 'Darkside',
'DIRTYDOZ.TTF' => 'Dirty Dozen',
'FELTMARI.TTF' => 'Feltmark',
'FIRESTARTER.TTF' => 'FireStarter',
'FLUBBER.TTF' => 'Flubber',
'gestures.ttf' => 'Gestures',
'GHOSTWRITER.TTF' => 'Ghostwriter',
'GREENFUZ.TTF' => 'GreenFuzz',
'HEMIHEAD.TTF' => 'HemiHead 426',
'hotpizza.ttf' => 'Hot Pizza',
'jmacscrl.ttf' => 'Johnny Mac Scrawl',
'johnnyfe.ttf' => 'Johnny Fever',
'Karate.ttf' => 'Karate',
'OASIS.TTF' => 'Oasis',
'Oktoberfest.ttf' => 'Oktoberfest',
'oliver.ttf' => 'Oliver',
'Oreos.ttf' => 'Oreos',
'Paintdrp.ttf' => 'Paint Drip',
'PEANUTS.TTF' => 'Peanuts',
'pirulen.ttf' => 'Pirulen',
'Plain Black Wide.ttf' => 'Plain Black WIde',
'ROCKB.TTF' => 'Rockwell Bold',
'Scood.ttf' => 'Scooby Doo',
'Simpsonfont.ttf' => 'Simpson',
'Sixties.ttf' => 'Sixties',
'Speedline.ttf' => 'Speed Line',
'tahoma.ttf' => 'Tahoma',
'UNDERGRO.TTF' => 'Underground',
'verdana.ttf' => 'Verdana',
'Yahoo.ttf' => 'Yachoo',
'yoshisst.ttf' => 'Yoshis Story',
'ZEROGIRL.TTF' => 'Zero Girl',
);

// Everything below this comment can remain unchanged.

$text = stripslashes($_GET['text']);
$filename = $_GET['filename'];
$size = $_GET['size'];

if (isset($_GET['render'])) {
Header ("Content-type: image/png");
$fonturl = $fontdir.'/'.$filename;
$textdims = ImageTTFBBox($size, 0, $fonturl, $text);
$im = imagecreate ($textdims[2]-$textdims[6]+10, $textdims[3]-$textdims[7]+10);
$white = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate ($im, 0, 0, 0);
ImageTTFText ($im, $size, 0, 0, -$textdims[5], $black, $fonturl, $text);
ImagePng ($im);
ImageDestroy ($im);
die();
} else {
?><HTML>
<head>
<title>YakTagz Live Font Previewer</title>
<style type="text/css"><!--
body {font-family:georgia, verdana; scrollbar-base-color:white; scrollbar-face-color:white; scrollbar-track-color:white; scrollbar-highlight-color:white; scrollbar-shadow-color:white; scrollbar-darkshadow-color:white; scrollbar-arrow-color:white}
h1 {font-family: trebuchet ms, verdana}
a:link, a:visited {color:blue;text-decoration:underline}
a:active, a:hover {color:red;text-decoration:none}
--></style>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#00ff00" alink="#ff0000">
<h1 align="center">Live Text Preview</h1>

<br />
<div align="center">
<table><tr><td>
<form method="get">
<p>Select Font:
<select name="filename">




<?
foreach ($fontnames as $thisfile => $thisname) {
print '<option ';
if ($filename == $thisfile) echo 'selected="selected" ';
print 'value="' . $thisfile . '">' . $thisname . '</option>' . "\n";
}
?>
</select>
</p>
<p>

<input type="hidden" name="size" value="<? if (!$size) echo "52"; else echo $size; ?>" size="2" />



</p>
<p>Text to preview: <textarea name="text" cols="15" rows="1"><? if
(isset($text)) echo $text; ?></textarea></p>
</td></tr></table>
<p><input type="submit" value="Preview Yaktag" /></p>
</form>
</div><? if (isset($filename) && isset($text)) { ?>

<center><p>
<img src="<?
echo $_SERVER['SCRIPT_NAME']."?render=1&filename=$filename&size=$size&text=".urlencode($text);
?>" /></p>
<? } ?>
<center>
<a href="ordertagz.htm" target="_blank">Order Your YakTagz Now</a><br>
<br>
<br>

If you have a specific font that is not listed, <a href=mailto:sales@yaktagz.com> Contact us</a> to workout the details. Due to the vast number of fonts available, we only list a small percentage of the font choices available.
</center>
</body>

If you can show me an example that would be great.. Thanks

Leafy
03-09-2008, 05:09 PM
<?php

//Font Previewer

$fontdir = '/fonts';
// The list of font filenames, together with their names.
// Use the format provided here in the example.
$fontnames = array (
'Ac.ttf' => 'AC',
'aftermat.ttf' => 'Aftermath',
'airmole.ttf' => 'Airmole',
'AlbertText-Bold.ttf' => 'Albert Text Bold',
'amsterdam.ttf' => 'Amsterdam',
'ANGLEPOI.TTF' => 'Anglepoise Lampshade',
'ANKLEPAN.TTF' => 'Ankle Pan',
'ArgosGeorge.ttf' => 'Argos George',
'arialbd.ttf' => 'Arial Bold',
'astronbo.ttf' => 'Astron Boy',
'Becker.ttf' => 'Becker',
'Bloody.ttf' => 'Bloody',
'CURLZ.TTF' => 'Curlz',
'darkside.ttf' => 'Darkside',
'DIRTYDOZ.TTF' => 'Dirty Dozen',
'FELTMARI.TTF' => 'Feltmark',
'FIRESTARTER.TTF' => 'FireStarter',
'FLUBBER.TTF' => 'Flubber',
'gestures.ttf' => 'Gestures',
'GHOSTWRITER.TTF' => 'Ghostwriter',
'GREENFUZ.TTF' => 'GreenFuzz',
'HEMIHEAD.TTF' => 'HemiHead 426',
'hotpizza.ttf' => 'Hot Pizza',
'jmacscrl.ttf' => 'Johnny Mac Scrawl',
'johnnyfe.ttf' => 'Johnny Fever',
'Karate.ttf' => 'Karate',
'OASIS.TTF' => 'Oasis',
'Oktoberfest.ttf' => 'Oktoberfest',
'oliver.ttf' => 'Oliver',
'Oreos.ttf' => 'Oreos',
'Paintdrp.ttf' => 'Paint Drip',
'PEANUTS.TTF' => 'Peanuts',
'pirulen.ttf' => 'Pirulen',
'Plain Black Wide.ttf' => 'Plain Black WIde',
'ROCKB.TTF' => 'Rockwell Bold',
'Scood.ttf' => 'Scooby Doo',
'Simpsonfont.ttf' => 'Simpson',
'Sixties.ttf' => 'Sixties',
'Speedline.ttf' => 'Speed Line',
'tahoma.ttf' => 'Tahoma',
'UNDERGRO.TTF' => 'Underground',
'verdana.ttf' => 'Verdana',
'Yahoo.ttf' => 'Yachoo',
'yoshisst.ttf' => 'Yoshis Story',
'ZEROGIRL.TTF' => 'Zero Girl',
);

// Everything below this comment can remain unchanged.

$text = stripslashes($_GET['text']);
$filename = escapeshellarg($_GET['filename']);
$filename = substr(1,strlen($filename) - 2,$filename);
$size = $_GET['size'];
if (isset($_GET['render'])) {
Header ("Content-type: image/png");
$fonturl = $fontdir.'/'.$filename;
$textdims = ImageTTFBBox($size, 0, $fonturl, $text);
$im = imagecreate ($textdims[2]-$textdims[6]+10, $textdims[3]-$textdims[7]+10);
$white = ImageColorAllocate ($im, 255, 255, 255);
$black = ImageColorAllocate ($im, 0, 0, 0);
ImageTTFText ($im, $size, 0, 0, -$textdims[5], $black, $fonturl, $text);
ImagePng ($im);
ImageDestroy ($im);
die();
} else {
?>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>YakTagz Live Font Previewer</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style type="text/css">
<!--
body {
font-family:georgia, verdana;
scrollbar-base-color:white; s
crollbar-face-color:white;
scrollbar-track-color:white;
scrollbar-highlight-color:white;
scrollbar-shadow-color:white;
scrollbar-darkshadow-color:white;
scrollbar-arrow-color:white
background-color: #FFF;
color: #000;
}
h1 {
font-family: trebuchet ms, verdana
}
a:link, a:visited {
color:blue;
text-decoration:underline
}
a:active, a:hover {
color:red;
text-decoration:none
}
-->
</style>
</head>
<body>
<div id="container">
<h1 style="text-align: center;">Live Text Preview</h1>
<br />
<div style="text-align: center;">
<form method="get">
<table>
<tr>
<td>
<p>Select Font:
<select name="filename">
<?php
foreach ($fontnames as $thisfile => $thisname) {
printf(
'<option%s value="%s">%s</option>'."\n",
($filename == $thisfile)?' selected="selected"':'',
$thisfile,
$thisname
);
}
?>
</select>
</p>
<p>
<input type="hidden" name="size" value="<? if (!$size) echo "52"; else echo $size; ?>" />
</p>
<p>
Text to preview:
<textarea name="text" cols="15" rows="1"><?php
if(isset($text))
echo $text;
?></textarea>
</p>
</td>
</tr>
</table>
<p>
<input type="submit" value="Preview Yaktag" />
</p>
</form>
</div>
<?php
if(isset($filename) && isset($text)) { ?>
<div style="text-align: center;">
<p>
<img <?php
echo 'src="'.$_SERVER['PHP_SELF']."?render=1&filename=$filename&size=$size&text=".urlencode($text).'"';
?> />
</p>
</div>
<?php
}
?>
<div style="text-align: center;">
<a href="ordertagz.htm" target="_blank">Order Your YakTagz Now</a>
<br />
<br />
<br />
If you have a specific font that is not listed, <a href="mailto:sales@yaktagz.com">Contact us</a> to workout the details.
Due to the vast number of fonts available, we only list a small percentage of the font choices available.
</div>
</div>
</body>
</html>


I don't think it's possible to put images in a selectbox. You could do a background-image on each of the elements though.