0

I want to make clickable tiles with people's names and pictures, for them to choose who they are. I would like all the tiles to redirect to the same page, just with different query params. Would it be best to just make div's that are hyperlinks? Or I was thinking maybe I should make it a form, where the action is the page to redirect to, with method=GET, and clicking any of the tiles would submit the form somehow with that tile as the form value?

Any suggestions for best way to do this? Thanks!

Christopher Shroba
  • 7,006
  • 8
  • 40
  • 68
  • 1
    I guess that's too broad. Equally general answer: use block div inside your anchor tags and either use javascript to capture clicks and issue AJAX requests to wherever you want to go or simply make links have separate hrefs. – zencodism Dec 18 '15 at 23:31
  • Thanks for commenting even though it was admittedly pretty broad! That makes sense, I'll go ahead and do that. – Christopher Shroba Dec 18 '15 at 23:32

1 Answers1

0

This doesn't require any javascript unless that's how you're rendering the HTML. You just need need an anchor tag (<a>) with your img and text inside. <div>s can't be hyperlinks, and technically shouldn't be wrapped with anchor tags. (With a little CSS you can make <span>s behave like divs if that's what your design needs.) You COULD use javascript to attach a click event to a div, but an anchor is cleaner and easier.

<a href="/mypage.html?name=bozo">
 <img src="bozo.jpg" width="100" height="100">
 <span>Bozo</span>
</a>
Community
  • 1
  • 1
case2000
  • 178
  • 1
  • 9