Results 1 to 9 of 9

Thread: Form Option Select Values

  1. #1
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Form Option Select Values

    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.

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    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 especially in regards to #8 posting computer code

  3. #3
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    How do I assign a URL to the array. Do you have an example of some code for this by chance?

    Thanks

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    Code:
    'aftermat.ttf' => 'aftermath.gif'
    Just replace the text with the image, then wrap it with the image tag when you echo it.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by alexjewell View Post
    Code:
    '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?

  6. #6
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by redrubi View Post
    You lost me on this part.. Can you provide an example on wrapping an image tag and echoing it?

    Anyone?????

  7. #7
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    please show us the whole code so we can better help you
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@ /\/\@|{
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  8. #8
    Join Date
    Feb 2008
    Posts
    10
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Code:
    <?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

  9. #9
    Join Date
    Jan 2008
    Posts
    32
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    PHP Code:
    <?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($size0$fonturl$text);
            
    $im imagecreate ($textdims[2]-$textdims[6]+10$textdims[3]-$textdims[7]+10);
            
    $white ImageColorAllocate ($im255255255);
            
    $black ImageColorAllocate ($im000);
            
    ImageTTFText ($im$size00, -$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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •