javascript search field + check box
hy guys,
I'm relatively new to javascript so I would need some help if you could.
I'm creating some web aplication for one company storage management and I made it to log everything that anyone does on the page, so I have 7 tipes of logs (sales-prodaja, article entry- unos artikala, article editing-izmjena artikala, article deleting-brisanje artikala, worker entry- unos radnika, worker editing-izmjena radnika, worker deleting-brisanje radnika). I made a table where all the logs are shown, and above the logs are check boxes to check wich log would the boss want to see, there is a filter field to if he would like to search for something specific. The check box alone works fine and the filter field too, but when a hide some records with checkbox (for example, I uncech sales checkbox and then its not shown), and then enter a word that I have in sales record the records showes. So waht I would like is when some logs are hidden with checkbox option, and something is entered in filter field I would like to filter just shown logs not hidden too.
picture:
http://img204.imageshack.us/img204/6722/picwcn.jpg
here is the code:
check box:
Code:
function showHideProdaja()
{
if(document.getElementById('prodaja').checked)
{
$("table tr[id='log']").show();
}
else
{
$("table tr[id='log']").hide();
}
}
function showHideUnosArtikla()
{
if(document.getElementById('unosArtikla').checked)
{
$("table tr[id='logUnosArtikla']").show();
}
else
{
$("table tr[id='logUnosArtikla']").hide();
}
}
function showHideEditArtikala()
{
if(document.getElementById('izmjenaArtikala').checked)
{
$("table tr[id='logEditArtikala']").show();
}
else
{
$("table tr[id='logEditArtikala']").hide();
}
}
function showHideBrisanjeArtikala()
{
if(document.getElementById('brisanjeArtikala').checked)
{
$("table tr[id='logBrisanjeArtikala']").show();
}
else
{
$("table tr[id='logBrisanjeArtikala']").hide();
}
}
function showHideUnosRadnika()
{
if(document.getElementById('unosRadnika').checked)
{
$("table tr[id='logUnosRadnika']").show();
}
else
{
$("table tr[id='logUnosRadnika']").hide();
}
}
function showHideEditRadnika()
{
if(document.getElementById('izmjenaRadnika').checked)
{
$("table tr[id='logEditRadnika']").show();
}
else
{
$("table tr[id='logEditRadnika']").hide();
}
}
function showHideBrisanjeRadnika()
{
if(document.getElementById('brisanjeRadnika').checked)
{
$("table tr[id='logBrisanjeRadnika']").show();
}
else
{
$("table tr[id='logBrisanjeRadnika']").hide();
}
}
filter field:
Code:
// When document is ready: this gets fired before body onload :)
$(document).ready(function(){
// Write on keyup event of keyword input element
$("#kwd_search").keyup(function(){
// When value of the input is not blank
if( $(this).val() != "")
{
// Show only matching TR, hide rest of them
$("#my-table tbody>tr").hide();
$("#my-table td:contains-ci('" + $(this).val() + "')").parent("tr").show();
}
else
{
// When there is no input or clean again, show everything back
$("#my-table tbody>tr").show();
}
});
});
// jQuery expression for case-insensitive filter
$.extend($.expr[":"],
{
"contains-ci": function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
i tried to do
Code:
// When document is ready: this gets fired before body onload :)
$(document).ready(function(){
// Write on keyup event of keyword input element
$("#kwd_search").keyup(function(){
// When value of the input is not blank
if( $(this).val() != "")
{
// Show only matching TR, hide rest of them
$("#my-table tbody>tr").hide();
if(document.getElementById('someLogID').style.display!='none'){//NEW LINE
$("#my-table td:contains-ci('" + $(this).val() + "')").parent("tr").show();
}
}
else
{
// When there is no input or clean again, show everything back
$("#my-table tbody>tr").show();
}
});
});
// jQuery expression for case-insensitive filter
$.extend($.expr[":"],
{
"contains-ci": function(elem, i, match, array)
{
return (elem.textContent || elem.innerText || $(elem).text() || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
and other similar things but when I try to enter anaything in the filter then nothing shows soo....
If anyone coluld please help me I would apriciate it.