znalazłem taki sobie skrypt w jquery i chciałbym nim wybierać kolumny do wyświetlenie danych z bazy sql ... ogólnie chciałbym załączać wyłączać dane kolumny te, które mi są potrzebne w danym momencie
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="../../css/base.css" type="text/css" media="screen" charset="utf-8"/> <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/> </head> <body> <div id="container"> <div id="header"> </div> <div id="content"> <div id="rankings"> <div class="list"> <select id="candidates" name="candidates" multiple="multiple" size="8"> </select> </div> <div class="list"> <select id="a-listers" name="a-listers" multiple="multiple" size="8"> </select> </div> <div id="controls"> <div> <input type="button" id="swapLeft" value=">" /> <input type="button" id="swapRight" value="<" /> </div> <div> <input type="button" id="swapLeftAll" value=">>" /> <input type="button" id="swapRightAll" value="<<" /> </div> <div> <input class="search" type="text" id="search" /> </div> </div> </div> </div> <div id="footer"> <p> © Copyright 2010 CelebriTracker Productions </p> </div> </div> </body> </html>
Kod pliku script.js
$(document).ready(function() { $('#swapLeft').click(function() { SWAPLIST.swap('#candidates', '#a-listers'); }); $('#swapRight').click(function() { SWAPLIST.swap('#a-listers', '#candidates'); }); $('#swapLeftAll').click(function() { SWAPLIST.swapAll('#candidates', '#a-listers'); }); $('#swapRightAll').click(function() { SWAPLIST.swapAll('#a-listers', '#candidates'); }); $('.invert').click(function(e) { SWAPLIST.invert($(this).parent().find('select')); e.preventDefault(); }); $('#search').keyup(function() { SWAPLIST.search("#a-listers, #candidates", $(this).val()); }); }); var SWAPLIST = {}; SWAPLIST.swap = function(from, to) { $(from) .find(':selected') .appendTo(to); } SWAPLIST.swapAll = function(from,to) { $(from) .children() .appendTo(to); } SWAPLIST.invert = function(list) { $(list) .children() .attr('selected', function(i, selected) { return !selected; }); } SWAPLIST.search = function(list, search) { $(list) .children() .attr('selected', '') .filter(function() { if(search == ''){ return false; } return $(this) .text() .toLowerCase() .indexOf(search) > - 1 }) .attr('selected', 'selected'); }
czy się ktoś mam pomysł jak to zrobić ?