-1

I've got a table of cities, ordered by alphabetic order, and I've got another table with the alphabet. I would like to select a letter in this table and fade out the cities who don't begin with this letter, only the cities with this initial.

Could anybody help me?

Wouter J
  • 39,482
  • 15
  • 97
  • 108
  • http://www.tripwiremagazine.com/2012/05/jquery-filter-sort-plugins.html – Wouter J Jul 20 '12 at 12:49
  • what is the structure of your page? is each city in its own cell? is each letter in its own cell? – jbabey Jul 20 '12 at 12:51
  • I used an alphabet who colors the letters who exist in each state, for example it will be black for Z in Florida and blue for the other letters. I want to click in these blue letters. I used HTTP requests to change in blue. I'm a beginner, so I don't want to use JQuery, I'd rather use Javascript. – Mijoro Nicolas Rasoanaivo Jul 20 '12 at 13:02
  • -1 you have to try more by yourself. else you are 'code shopping', wich is not what we are doing here. – r4. Jul 20 '12 at 13:41
  • I'd like to just point out that jQuery IS JavaScript. – jsmith Jul 20 '12 at 13:57

1 Answers1

0

Actually that's quite simple. Bind an onclick handler (a simple function) to the rows of the alphabet table. In that function, get the clicked letter from the mouse event, iterate through the rows of your city table and check if the city name begins with the clicked letter. You can then either display or hide that row with element.style.display = "block" / "none";

Btw, iterating through tables in JavaScript is simple, you can use this solution:
How do I iterate through table rows and cells in javascript?

I won't post any code for now, you should try to implement something by yourself first.

Community
  • 1
  • 1
Aletheios
  • 3,800
  • 2
  • 28
  • 43