lamrin
lamrin

Reputation: 1441

rails select one image from list of images

i have image collection

  @images = Image.find(:all)

and displaying it like this

  <%@images.each do|image|%>

  <%= image_tag image.photo.url(:original), :id=>image.id, :class=>'image' %>

  <%end%>

but, i want to put images as list and select one of the image before submitting the form,

i there any way to put these images in to selectbox.. or is there any other approach to select image from list of image

please guide me with solution

thanks

Upvotes: 2

Views: 2178

Answers (1)

lebreeze
lebreeze

Reputation: 5134

This is more of an html, css, javascript question than a Rails specific one.

How about a list of checkboxes representing the chosen image, with the actual images within the corresponding labels. That way clicking on an image will highlight the appropriate checkbox to be submitted. Now your functionality should be complete.

Then you can use a combination of javascript and css to hide the checkboxes and ensure the selected image is visually highlighted.

Upvotes: 2

Related Questions