1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Rep Power

    Bind image to cfgrid

    I have a HTML cfgrid that I'm trying to bind an image to so that as they select each item in the grid I than show the picture associated with that record next to the grid. It seems like I should be able to do this with a cfinput type=image and a bind statement, but I can't seem to figure out the syntax to make it work.

    I've done a bit of looking and it seems everyone is using flash forms to show images with cfgrid, but can't seem to find any answers on how to make this work with an HTML cfgrid. I'm not trying to show the image within the cfgrid, just a way to show it next to it without having to use frames.

    Is this possible?
  2. #2
  3. No Profile Picture

    Join Date
    Jun 2002
    Raleigh, NC
    Rep Power
    type="image" is for using an image in place of a standard HTML button. So it doesn't do what you're looking for. You'll need to use JavaScript to handle this. Something like:

    // Set init() to run when the page loads using AjaxOnLoad().
    function init() 
    	grid = ColdFusion.Grid.getGridObject("MyGrid"); 
    	grid.addListener( "rowclick", gridRowClickHandler ); 
    function gridRowClickHandler( grid, rowIndex, e ) 
    	var record = grid.getDataSource().getAt(rowIndex);
    	var imageURL = record.data.imageURL; // Or whatever key you're using to store the image URL 
    	document[img_name].src = imageURL;

IMN logo majestic logo threadwatch logo seochat tools logo