我正在使用Iconselect,我想问一下如何将实际和/或选定的值传输到隐藏字段中-我找不到解决方案:(

<input type="hidden" id="recommandation" name="recommandation" value="" />
...
<script>
 var iconSelect;
 window.onload = function(){
    iconSelect = new IconSelect("my-icon-select",
        {'selectedIconWidth':24,
        'selectedIconHeight':24,
        'selectedBoxPadding':1,
        'iconsWidth':20,
        'iconsHeight':20,
        'boxIconSpace':1,
        'vectoralIconNumber':4,
        'horizontalIconNumber':4});
    var icons = [];
    icons.push({'iconFilePath':'/images/sampledata/eval-1.jpg', 'iconValue':'1'});
    icons.push({'iconFilePath':'/images/sampledata/eval-2.jpg', 'iconValue':'2'});
    icons.push({'iconFilePath':'/images/sampledata/eval-3.jpg', 'iconValue':'3'});
    iconSelect.refresh(icons);
 };
</script>


非常感谢

最佳答案

快速浏览IconSelect时,您似乎可以执行以下操作:

$('#my-icon-select').on('changed', function(){
    $('#recommandation').val(iconSelect.getSelectedValue());
});

关于javascript - 如何将实际值输入隐藏字段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24391496/

10-10 00:25