JQuery: Check to see if table row containing certain values exists already?

You might be able to use :contains(): $('#tblspecializations tr > td:contains(Some Value) + td:contains(2)'). Length - Example Be aware, though, that :contains() will return the element if the given string is matched anywhere in the text of the element.

1 Worked like a BOMB, many thanks indeed. I am not too concerned about the values being similar as they are predefined values anyway. I simple added the following function and all worked great: if($('#tblspecialization td:contains('+$slabel+')').

Length){ alert('A specialization of the same type and months has already been entered. '); return false; } Big up to you for your help – webfac Sep 7 '10 at 11:06 1+ to you for your help and time and simple effective answer – webfac Sep 7 '10 at 11:10 @webfac: glad I could help :-) – Andy E Sep 7 '10 at 11:13 1 +1 for a nice and short solution, and for teaching me something new :) – Giu Sep 7 '10 at 11:37.

I'd suggest you hold your data in some data structure (an (associative) array for example). Thus you will verify the data in the structure, rather than in the DOM.

I really like this approach and am sure it is better practice, but for this scenario all the code is structured in a certain manner already, albeit not the best manner, I needed a solution I could simply 'plug in' to the current logic. Many thanks for your guidance though! Much appreciated – webfac Sep 7 '10 at 11:05 1+ to you for your help and time – webfac Sep 7 '10 at 11:10.

To put it short, the following code in the click() handler should help you in your situation; you can see the whole code in action: $(function(){ $("#btn"). Click(function(){ var table = $("#tblspecializations"); var firstTd = $("td:first", table); var secondTd = firstTd.next(); if(firstTd.text() == $("#dropdown").val() && secondTd.text() == $("#num").val()) alert("Error: You're trying to add the same entry"); }); }); Short explanation: By using td:first in the selector, you're getting the first column in your table, and by using the next() function, your getting its sibling, namely the second column.

This also works for me, however I found Andy E's answer to be the shortest solution. Thank you for your time though! It does not go unnoticed.

– webfac Sep 7 '10 at 11:07 1+ for you for your help and time – webfac Sep 7 '10 at 11:09 @webfac No problem; you're welcome, and thanks for the upvote. – Giu Sep 7 '10 at 11:13.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions