Quote:
Originally Posted by liamsorsby
i need my ratio buttons, when clicked, to change my main product image. each button changing the main image into a different image. but i'm unable to use the value="" in the input as it has a variable already. i need about 13 ratio buttons.
|
Code:
function picFromRadio( imgHolder, imgArray, btnGroup )
{
for(var i=0, len=btnGroup.length; i<len; i++)
btnGroup[i].onclick = (function(h, a, idx){ return function(){ h.src = a[idx]; } })(imgHolder, imgArray, i);
}
The parameters are
references to:
- The image placeholder
- An array holding the image filenames
- The group of radio buttons
Call the function anywhere below all the involved elements.