I have a virtual store in which it generates the following HTML of a select
that has image inside it. I would like to hide the input
(ball of the select radio) and display only one border in the image that is selected that will match the select
selected.
Important
Theinput
radiowillautomaticallybegeneratedinthestorewithhtml
identicaltothis,thedifferencewillbethatineachproducttheinput
namewillbedifferent,inthesemyexampleshavethenamesoption[238]
andoption[239]
.Butthestorewillgeneratemoreotherslikeoption[240]
,option[241]
...
Ananswerbelow@MateusVelosohelpedmeifmycodehadonlyinputradio
withitsproperoptions.Butmycasewillhavemorethaninputradio
.Withthis,thesolutionofitleavesonlythelastinputradio
markedwiththeborderandtheotherinputs
withitsdueoptionsdoesnotshowwhattheuser'schoicewas. See the demo here.
The input
will be single-selection, but will have more than one inpupt radio
each with its options and only one of them can be checked. For example, there is the% Color "Insole Color" with their respective colors (only one of them can be marked), then it has "Color Solved" with their respective colors and so it goes. The fact is that they will not have a defined name, they will be generated automatically. In the example link I placed, the "Insole Color" has input radio
but may have a different name.
Here you can see the code working:
#product .radio {
display: inline-block;
margin-right:10px;
}
.radio {
position: relative;
display: block;
margin-top: 10px;
margin-bottom: 10px;
}
.radio input[type=radio] {
position: absolute;
margin-top: 4px;
margin-left: -20px;
}
#product .radio label {
display: block;
background: none;
color: #111111;
text-align: center;
border: none;
padding: 0;
font-size:0;
}
#product .radio label input {
margin-left: 15px;
}
<div id="product">
<div class="form-group required">
<label class="control-label">Cor Palmilha</label>
<div id="input-option238">
<div class="radio">
<label>
<input type="radio" name="option[238]" value="56">
<img src="https://s19.postimg.org/krdm2veer/cor-produto-cinza.jpg"alt="Cinza" class="img-thumbnail">
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="option[238]" value="55">
<img src="https://s19.postimg.org/da4ennovn/cor-produto-verde.jpg"alt="Verde" class="img-thumbnail">
</label>
</div>
</div>
</div>
<div class="form-group required">
<label class="control-label">Cor Solado</label>
<div id="input-option239">
<div class="radio">
<label>
<input type="radio" name="option[239]" value="66">
<img src="https://s19.postimg.org/krdm2veer/cor-produto-cinza.jpg"alt="Cinza" class="img-thumbnail">
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="option[239]" value="67">
<img src="https://s19.postimg.org/da4ennovn/cor-produto-verde.jpg"alt="Verde" class="img-thumbnail">
</label>
</div>
</div>
</div>
</div>