javascript - Populate form text field with button image -


I have seen this question / answered here

This essentially what I want, but Instead of the radio button I want to use my own images to use as buttons, so that you can click on the "tag" image and then it will become almost transparent or it will fill in the form field.

For a search form, so that people can click on the button by saying "restaurant" and then it will fill in the farm field with the restaurant, they can still type in the main search field if They want, but to use it a little bit of guidance to users

If there is any way, we can do this without javascript, but it is terrible but maybe I can not see it.

Hopefully this is relatively simple.

P> Thanks in advance

Click!

Enjoy :)

HTML:

  & lt; Field set data-roll = "control group" data-type = "horizontal" & gt; & Lt; Div & gt; & Lt; img class = "stam" alt = "restaurant" src = "img1.jpg" /> & Lt; img class = "stam" alt = "gym" src = "img2.jpg" /> & Lt; / Div & gt; & Lt; / Fieldset & gt; & Lt; Br> & Lt; Form & gt; & Lt; Input type = "text" & gt; & Lt; / Form & gt;  

JS:

  $ ('. Stam'). ('Click', function () {$ ('input [type =' text ']'). Val ($ (this) .attr ("alt");});    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -