1. 程式人生 > >php多條件篩選功能的實現

php多條件篩選功能的實現

例如

表單篩選核心函式

function Filter(a, b) { 
    var $ = function(e) { 
        return document.getElementById(e); 
    } 
    var ipts = $('filterForm').getElementsByTagName('input'), result = []; 
    for (var i = 0, l = ipts.length; i < l; i++) { 
        if (ipts[i].getAttribute('to') == 'filter') { 
            result.push(ipts[i]); 
        } 
    } 
    if ($(a)) { 
        $(a).value = b; 
        for (var j = 0, len = result.length; j < len; j++) { 
  
            if (result[j].value == '' || result[j].value == '0') { 
                result[j].parentNode.removeChild(result[j]); 
            } 
        } 
        document.forms['filterForm'].submit(); 
    } 
    return false; 
}