selectFilter for kbox

https://confluence.kace.com/display/TS/The+best+way+to+run+custom+javascript+in+the+K1+web+interface

by Gerald Gillespie

HTML

<script src="https://support.kace.com/jkuery/www/js/jquery.selectFilter.js"></script>
<table>
    <tr>
        <td class="wrapwordInputFormat" colspan="2">Status:&nbsp;</td>
        <td class="inputFormat">
            <select style="width:300px" onchange="checkStatus();" id="fields[status_id]"
            name="fields[status_id]">
                <option selected="" value="4" title="New">New</option>
                <option value="1" title="Opened">Opened</option>
                <option value="2" title="Closed">Closed</option>
                <option value="3" title="Need More Info">Need More Info</option>
            </select>
        </td>
    </tr>
</table>
<div><span>value</span><span id="thevalue" /></div>
<input id="checkit" type="button" value="checkvalue of select"/>

JavaScript

function checkStatus(){
 return true;   
} // end checkStatus placeholder for OEM handler

$('#fields\\[status_id\\]').selectFilter();



// just a sanit check to make sure
$('#checkit').on('click', function(){
    var $f=$('#fields\\[status_id\\]');
    alert($f.val() + ' '+$f.find('option:selected').text());
}); // end on click check



// TODO: add support for wilcards (at least SQL equivalent) and trim in search strings

// TODO : do not allow blank entries.


//TODO : trigger change  event of select