Solved

Use jQuery to remove rows from table

Posted on 2011-09-29
7
339 Views
Last Modified: 2012-08-14
Is there a way to HIDE all rows that don't have

"Pick-up Instore"

as the  inner text for lblDisplay?



		<table cellspacing="0" cellpadding="3" rules="cols" border="1" id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping" style="background-color:Transparent;font-size:12px;height:20px;width:300px;border-collapse:collapse;">
			<tr style="color:White;background-color:Gray;">

				<th align="left" scope="col">Select Shipping Method</th><th align="right" scope="col">Amount</th><th align="right" scope="col">&nbsp;</th>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$0')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl02_lblDisplay">USPS Media Mail</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl02_lblAmount">$5.95</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$0')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$1')">
				<td>

<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl03_lblDisplay">USPS Express MAil</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl03_lblAmount">$8.45</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$1')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$2')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl04_lblDisplay">FedEx Second Day Air</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl04_lblAmount">$12.00</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$2')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$3')">

				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl05_lblDisplay">FedEx Overnight</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl05_lblAmount">$20.00</span>
</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$3')"></a></td>
			</tr><tr onclick="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$4')">
				<td>
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl06_lblDisplay">Pick-up Instore</span>
</td><td align="right" style="width:0px;">
<span id="ctl00_ContentPlaceHolder1_ShoppingShippingMethods1_gvShipping_ctl06_lblAmount">$0.00</span>

</td><td align="right" style="width:0px;"><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$ShoppingShippingMethods1$gvShipping','Select$4')"></a></td>
			</tr>
		</table>

Open in new window




This is what the table looks like at runtime:

 ship method
0
Comment
Question by:knowlton
  • 4
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36817143
Use : $("tr:not(:contains('Pick-up Instore')):not(:eq(0))","table").hide();
Test page : http://jsfiddle.net/v6W9K/

Or: $("tr:not(:contains('Pick-up Instore'))","table").hide();
Test page : http://jsfiddle.net/v6W9K/1/

0
 
LVL 5

Author Comment

by:knowlton
ID: 36817275
I need it to only operate on tables with the following in their id:

table tag id contains gvShipping
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 36817277
thx
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 5

Author Comment

by:knowlton
ID: 36817292
Is this correct?

$("tr:not(:contains('Pick-up Instore'))", "table[id*='gvShipping']").hide();
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36817313
look fine, you're using the contain selector

 "table[id*='gvShipping']"

<< a table where where its ID contains gvShipping >>
0
 
LVL 5

Author Comment

by:knowlton
ID: 36817335
Thanks again!!!!
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36817337
you're welcome, have fun!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question