2014-06-24 29 views
0

我正在使用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> 

非常感謝

回答

1

在採取快速看一下IconSelect,看來你可以這樣做:

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

我不知道iconselect從未使用過它,但使用jQuery操縱值,如果它在這個隱蔽的外觀也沒關係:

http://api.jquery.com/val/

2
$("id-of-selector").on('blur', function(){ 
    $('#recommandation').val = this.val; 
}); 

var element = document.getElementById('id-of-selector') 
element.addEventListener('blur', function(e){ 
    document.getElementById('recommandation').value = element.value; 
}); 
相關問題