+1
New discussion
Answer
It’s definitely something you can do, yes
This implies some modifications to the javascript, so that instead of filtering one table, it would filter all tables which are contained in a specific part of the page.
For example:
document.getElementById('toFilter');
And wherever there is a loop over the table’s rows, you should add an extra loop around it, to loop over all sub tables.
I’ll gladly help you if you want to try it.
+1
New discussion
Answer
So would that in effect get the filter function to repeat the process over a number of table references? Would ‘toFilter’ have to be classified as a collection of table Id’s? Sorry I’m very much a beginner when it comes to this, trying to learn though.
Do you think something along the lines below would work, please be as critical as you can. Thankyou so much for your help.
function filter (phrase, id1,id2,id3){ var words = phrase.value.toLowerCase().split(" "); var table = document.getElementById(id1); var ele; for (var r = 1; r < table.rows.length; r++){ ele = table.rows®.innerHTML.replace(/<[^>]>/g,""); var displayStyle = ‘none’; for (var i = 0; i < words.length; i+) { if (ele.toLowerCase().indexOf(words[i])>=0) displayStyle = ’’;
var words = phrase.value.toLowerCase().split(" ");var table = document.getElementById(_id2); var ele; for (var r = 1; r < table.rows.length; r++){ ele = table.rows®.innerHTML.replace(/<[^>]>/g,""); var displayStyle = ‘none’; for (var i = 0; i < words.length; i+) { if (ele.toLowerCase().indexOf(words[i])>=0) displayStyle = ’’;
var words = phrase.value.toLowerCase().split(" ");var table = document.getElementById(_id3); var ele; for (var r = 1; r < table.rows.length; r++){ ele = table.rows®.innerHTML.replace(/<[^>]>/g,""); var displayStyle = ‘none’; for (var i = 0; i < words.length; i+) { if (ele.toLowerCase().indexOf(words[i])>=0) displayStyle = ’’;
else { displayStyle = ‘none’; break; } } table.rows®.style.display = displayStyle; } }
+1
New discussion
Answer
I’m not sure about your goal, you want “one” filter to filter over many tables? Input filter should be present above the first one then?
First you can “only” add the filter form if you are in the first table:
<pre>
if (t == 0 && element.attributes[‘class’] && …) { … }
(at the end of the javascript file)
Then in the filterTable(input, element); part, reloop over all tables to add each to the onkeyup event.
Something like:
<pre>
It’s just one way to do it, simple. You tell me if it’s good.
+1
New discussion
Answer
Sorry it tried to compile the form at the end of the script,
I had tried to use the same basic version of your form with the form calling the function filter(this,‘Id1’,‘Id2’,‘Id3’,1)
+1
New discussion
Answer