tags:

views:

135

answers:

1

ok, so I have a table with the following:

<table id="servertable">
     <tr>
     <th scope="col">Server Name</th><th scope="col">Location</th><th scope="col">Status</th>
     </tr><tr><td>servername1</td><td>pathtoserver1</td><td>Unknown</td></tr>
     <tr><td>servername2</td><td>pathtoserver2</td><td>Unknown</td></tr>
     <tr><td>servername3</td><td>pathtoserver3</td><td>offline</td>
     </tr>
    </table>

and am trying to update status of a server (using jquery) based on the "pathtoserver", say, the javascript function receives, "pathtoserver2" and "online". I would like to located the server in the table and replace the value "Unknown" or whatever there might be with "online".

I've tried something such as this: $('#servertable td').find("#" + server); - to find the server, but that's looking for id, so, I'm not sure whether I need to assign an id to the containing the "pathtoserver" values, or if there some way to use ".each(function(..)" construct to located it and consequently update it.

so I used this: $('#servertable td:contains(' + server + ')')

and this almost works, except that I need to find exact match, so I change it to:

$('#servertable td:eq(' + server + ')')

However now, it only finds the first one (I think), how do I find all exact matches?

A: 

This should find the td with the server name, assuming the variable is called 'server':

$('#servertable td:contains(' + server + ')')

To get the next td, you just add .next() to that.

Daniel Roseman
I changed it to td:eq(' + server + ')'), however now if I have multiple values with the same name in the table, it only finds one..?
ra170