Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2013, 01:09 PM   PM User | #1
vilim
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
vilim is an unknown quantity at this point
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.
vilim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:58 AM.


Advertisement
Log in to turn off these ads.