2014年1月14日 星期二

Multiple Select Move (雙select移轉)

相信許多人都知道 Select 可以做到 Mutiple 的移轉功能,在前端顯示效果的功能部份是達到了,但是一旦傳送表單之後,卻發現怎麼 Select 本身的參數值卻不是自己要的資料。這是因為 jQuery 確實幫你處理了功能面的部份,如下:

$().ready(function() {  
 $('#add').click(function() {  
  return !$('#select1 option:selected').remove().appendTo('#select2');  
 });  
 $('#remove').click(function() {  
  return !$('#select2 option:selected').remove().appendTo('#select1');  
 });  
}); 

上面這個語法實現了 Select 左右移動的功能,但是在傳遞資料的部份上還是少了需要的資料,因此我們必須在撰寫一段語法來輔助並確定傳送需要的資料,如下:

$('form').submit(function() {  
 $('#select1 option').each(function(i) {  
  $(this).attr("selected", "selected");  
 });  
 $('#select2 option').each(function(i) {  
  $(this).attr("selected", "selected");  
 });  
});

上面的語法可以確定我們兩邊的 Select 資料,每一筆都確定POST到後端程式處理


2014年1月7日 星期二

IE 8 CSS BarCode條碼 無法顯示

在IE 8 中ttf副檔名的字型會有顯示問題,因此需要轉換成eot的附檔名:


  1. http://www.kirsle.net/wizards/ttf2eot.cgi 這個網站提供 ttf 轉換 eot 的功能.
  2. CSS設定: 
          @font-face {
              font-family: 'C39HrP24DhTt';
              src: url('font_filename.eot');
              src: url('font_filename.eot?iefix') format('opentype'),
                    url('font_filename.ttf') format('truetype');
              font-weight: normal;
              font-style: normal;
           }