At the moment, everything looks like this jsfiddle.net/x6uqtLab/6/, but when certain radiobutton is triggered, you need to display an image not corresponding to the jpg button pressed (as in my code), but a 3D model. Link to one of them https://sketchfab.com/models/176738e6a3cf4bf486bce3abe284c0d4/embed I'm not strong in javascript, so please your help.
HTML -----------
<div id="rows" class="rows"> <div class="row"> <img src="" width="80"> <label><input type="radio" name="1" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="1" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="1" class="radio"></label> </div> <div class="row"> <img src="" width="80"> <label><input type="radio" name="2" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="2" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="2" class="radio"></label> </div> <div class="row"> <img src="" width="80"> <label><input type="radio" name="3" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="3" class="radio"></label> <img src="" width="80"> <label><input type="radio" name="3" class="radio"></label> </div> JS ----------------------------
var imageToggle = (function(doc){ var box = doc.querySelector('#rows'), rows = box.querySelectorAll('.row'), rowCount = rows.length, toggleAll = [], cartes = [], data = {}, /** * @type Function * @return {[]} */ getCheckeds = function() { var checkeds = toggleAll.filter(function(toggle){ return toggle.checked; }); return checkeds.map(function(toggle, i){ return toggle.value; }); }, /** * @type Function * @param {[]} arr * @return {[]} */ cartesianProduct = function (arr) { return arr.reduce(function(a,b){ return a.map(function(x){ return b.map(function(y){ return x.concat(y); }) }).reduce(function(a,b){ return a.concat(b) },[]) }, [[]]) }; [].forEach.call(rows, function(row, i){ var toggles = row.querySelectorAll('[type="radio"]'); cartes[i] = []; [].forEach.call(toggles, function(toggle, j){ cartes[i][j] = toggle.value = j; toggleAll.push(toggle); }); }); cartes = cartesianProduct(cartes); return function(images, callBack) { callBack = callBack || function(){}; if(images.length != cartes.length) { throw new Error('ΠΠΎΠ»ΠΆΠ½ΠΎ Π±ΡΡΡ ' + cartes.length + ' ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ'); } images.forEach(function(image, i){ data[cartes[i].join('-')] = image; }); toggleAll.forEach(function(toggle){ toggle.addEventListener('change', function(){ var checkeds = getCheckeds(); if(checkeds.length == rowCount) { callBack(data[checkeds.join('-')]); } }); }); }; })(document); var result = document.querySelector('#result'), len = Math.pow(3, 3), images = [], i = 0; for(; i < len; i++) { images.push('image-' + (i + 1) + '.jpeg'); } imageToggle(images, function(imageUrl){ result.innerText = imageUrl; });