Skip to main content
Inspiring
March 24, 2007
Question

Avatars Question

  • March 24, 2007
  • 3 replies
  • 301 views
I have an Control Panel of the User where I givehim the option to select the avatar from the avaliable avatars.

The avatas are avaliable in a folder called AVATARS and can be displayed using the cfselect command and defing the option of each avatar.

But problem lies two ways:

1. I have around 700 avatrs, I display 700 times the option dialog box, is there any easy way to do this.

2. I want when the user select the avatar from the srop down menu, the preview should be displayed on the image field next to the select drop down box.

if anyne has some idea how to implemnt this, plz let drop some words hre.

    This topic has been closed for replies.

    3 replies

    Inspiring
    March 24, 2007
    A better solution might be:
    instead of displaying a drop down box with 700 entries, why not use cfdirectory to obtain a CF query of your objects and then use a combination of a thumbnail view and pagination to allow your users to page forward / page backward through your 700 avatars.
    March 24, 2007
    Is that folder of images on the server? If so, you can use <CFDIRECTORY ACTION="list" NAME="foo" ... > against the images folder to obtain the names of the files. Then do a <CFLOOP QUERY="foo" ... > to set your <OPTION> tags.
    gavy81Author
    Inspiring
    March 24, 2007
    I amusing this approach but unable to get the relevant infomation..

    <cfselect name="avatar" required="yes">
    <cfdirectory action="list"
    name="list_images"
    directory="#Application.file_path#/images/small/Avatars">
    <cfloop query="list_images">
    <option value="#list_images#">#list_images#</option>
    </cfloop>
    </cfselect>

    #Application.file_path#/ this picks the siteurl from the application.cfm tag.

    the output hows only the #list_images# instaead, i do not what is happening

    March 24, 2007
    I'll take a stab at this one.

    Why are you displaying the dialog box 700 times? Take the SELECT tag out of the loop and only place the OPTION tag within the loop.

    If you want the preview image displayed when the user selects an avatar, remember - ColdFusion is a server-side language. You will have to download ALL avatar preview images and use something like JavaScript (a client side language) to display the preview image when the user clicks an avatar in the select box.
    gavy81Author
    Inspiring
    March 24, 2007
    Thanks, But the images of avatars are locatedin the folder not in the database, how that i do,

    The avatar is selected like this:

    <cfselect name="avatar" required="yes">
    <option value="">Select One..</option>
    <option value="images/small/red.jpg" selected="selected">Red</option>
    <option value="images/small/blue.jpg">Blue</option>
    <option value="images/small/yellow.jpg">Yellow</option>
    <option value="images/small/black.jpg">Black</option>
    <option value="images/small/metal.jpg">Metal</option>
    <option value="images/small/white.jpg">White</option>
    </cfselect>

    so if i save all the images 700 in the folder of images/small

    then how i do i loop from the folder to get the images and of javascript you told me abt, that's fine..

    I got your Ideas in javascript but still confused about the the above mentioned statement..