Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:40:38+00:00 2026-06-09T16:40:38+00:00

I am trying to hide an input box if the preceding input box’s value

  • 0

I am trying to hide an input box if the preceding input box’s value is the same e.g.

City     Id    Name

NY        1     James
NY        2     John
TOKYO     3     Jane
TOKYO     4     June

I want to hide the second NY and the second TOKYO (NB:only the city, the Id and Name should remain).

I am using the jQuery script below:

<script>

$(function(){

var tr_no = $('.city').length;

for(i=1; i<=tr_no; i++)  {

    if($(".city:eq("+i+")").val() == $(".city:eq("+i+++")").val()){

        $(".city:eq("+i+1+")").css({'display':'none'});

        }

    }


});

</script>

It is not working. Firebug Console does not return any errors. Any help on how to continue this on jQuery will much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:40:39+00:00Added an answer on June 9, 2026 at 4:40 pm

    For organized output: http://jsfiddle.net/mattblancarte/mnWH2/10/

    var tr = $( 'tr' ),
        duplicates = [];
    
    tr.each( function( k,v ){
      var elem = $( v ),
          child = elem.children().slice(0,1),
          city = child.text();
    
      if( $.inArray( city, duplicates ) > 0 ){
        child.empty();    
      } else {
        duplicates.push( city );
      }
    });
    

    For unorganized output: http://jsfiddle.net/mattblancarte/mnWH2/8/

    $( 'tr' ).each( function( k,v ){
      var elem = $( v ),
          prev = elem.prev().children().slice(0,1).text(),
          child = elem.children().slice(0,1),
          city = child.text();
    
      if( prev === city ){
        child.empty();    
      } 
    });
    

    ​

    Note:: I don’t think you want to use display:none;. This may shift the table around… Maybe visibility:hidden would be a better option. I just empty the cell.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to hide elements with the same class name (float_form), but I'm also
I am trying to hide the div class hideme based on value of full_day
I'm trying to hide a div if certain value are selected in a drop
I am trying to use a little jQuery to hide the initial value in
i am trying to send the contents of an input box to a php
I am trying to open a have a select box show an input box
<input type=radio id=incomplete name=app_status value=incomplete>Incomplete Application<br> <input type=radio id=complete name=app_status value=complete>Complete Application<br><br> <div id=app_box>
I'm trying to make a check box to show/hide a HTML element, but I
This is a follow up question. I am trying to get a input box
I'm trying to get the value of an input, but I can't have this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.