Hiding rows from a table populated by a database

F

Fix_Metal

Hello all. I'm new to this group :)
I have a problem with javascript language.
I'm making an .asp page with some integrated Javascript functions. The
page consists of some HTML selects and a table.
The table is obviously populated from a database :) so it is dynamic.

The database contains a field containing some names. This field is not
a PK, thus the names can be repeated very easily).
I want the user to be able to see all the rows from the DB as default.
Plus, the user could, by selecting the name contained in a listbox,
filter up the table, in order to see just the rows which contain the
name selected.
I'm just making myself crazy to do this.
The <select> (listbox) is done like this (ASP + HTML):
<select name='persona' id='persona' onchange='swap();'>
<%
For i = proprietari.StartIndex() to proprietari.StopIndex()
response.write "<option
value='"&proprietari.data(i)&"'>"&proprietari.data(i)&"</option>"
next
%>
</select>

I use a class to handle dynamic arrays in ASP, don't bother too much
about that.
This makes my listbox, with the first element valued to "" (clicking on
it will make all the rows to be seen); the other elements are the names
extracted from the DB, sorted alphabetically, like this:

Andrew
Clark
Cartman
Luke
Mike

and so on to the end.

The logic I implemented previously is the following:

When I make my table via ASP, I make my rows like "<tr
id='name_from_db' >". Then I made my listbox containing the names. On
the event "onChange" I associated the "swap()" javascript function.
It controls which is the name selected in the listbox. Then it should
hide all the rows which ID is not the one selected in the listbox.
I used the table.deleteRow and row.rowIndex .
Though it seems that rowIndex doesn't permit to "loop".
Let's make an example. When I select the name "Andrew", I expect the
function to delete all the rows which ID is NOT "Andrew".
I loop on the listbox to get the names. I find "Andrew", but I do not
need to delete those rows, so I jump to the next element.
I find Clark. Fine, all rows with Clark as ID needs to be deleted. Once
I do table.deleteRows(document.getElementById("Clark").rowIndex) , 1
row with Clark gets deleted. Then rowIndex resets to -1, even the table
STILL CONTAINS Clark's things!

I don't know if I've been clearly enough. Just asking a little help ;)
thx in advance to all the ppl who'll help me ;)




The question is: how can I do this? This piece of javascript is going
to be executed by many browsers (IE, Firefox and Solaris Mozilla
mainly), so I must make the most standardized code....
 
F

Fix_Metal

I made it by myself, finally.
Just asking what to use instead of table.deleteRow to make those rows
hided instead of getting deleted :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top