Jump to content

[SOLVED] Comparison - Mark if data is found more then once.


funstad

Recommended Posts

Hey all,

 

I'm looking for a way to mark all matching id's

So if a id is found more then one time it has to been marked (red in jsfiddle)

 

I already solved it for 1 id but now I'm searching to do this for multiple id's.

 

Look on jsfiddle for what i already achieved .

 

http://jsfiddle.net/Crezzur/7wk27w5d/

Edited by funstad
Link to comment
Share on other sites

I'm looking for a way that it automatic search for all values and not only 1 specif

so im also trying to get rid off

highlight('4');

So it needs to highlight all data-convid="id" that's shown more than 1 time

 

 

I have a comparison table and every feature has it own idfor example

screen color = (1) Black, (2) Red, (3) GreenWeight = (4) 1kg, (5) 5kg, (6) 11kgAnd when people compare two or more products i want to search by the id number if it is shown more than 1 time on the page,

if it is shown more than one time products has the same value.

 

This is my goal: same features are getting marked with green color.

 

ezTEoZM.jpg

Edited by funstad
Link to comment
Share on other sites

Yes that my goal so that when I'm starting a comparison it automatically color the field which are the same in green.as you can see here

http://dev.fietsendezwaluw.be/webshop/index.php?controller=products-comparison&compare_product_list=1|3

multiple features are active and i want to mark the ones that are the same so my customers see much better which different there is between products

Edited by funstad
Link to comment
Share on other sites

Perhaps something like...

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"/><title>title</title><style>table, th, td { border: 1px solid black; }</style><script>window.onerror = function(a, b, c, d){alert('Javascript Error:n'+a+'nURL: '+b+'nLine: '+c+'  Column: '+d);return true;}</script><script>'use strict';window.onload = init;function init() {document.getElementById('btn1').onclick = searchdups;}function searchdups(){ var list = document.getElementsByTagName('TD'); var attr; var seen = []; var dups = []; for (var i=0, len=list.length ; i<len ; i++){    attr = list[i].getAttribute('data-convid');    if(attr != null){       if (seen.indexOf(attr)==-1){          seen.push(attr);       }else{          if (dups.indexOf(attr)==-1){             dups.push(attr);          }       }    } } for (var i=0, len=list.length ; i<len ; i++){    attr = list[i].getAttribute('data-convid');    if (attr!=null && dups.indexOf(attr)!=-1){       list[i].style.backgroundColor = 'green';    } }}//end of function</script></head><body><table><tr>	<td class="message">Screensize</td>	<td data-convid="4" class="conversationid">Screen 4"</td>	<td data-convid="8" class="conversationid">Screen 8"</td>	<td data-convid="4" class="conversationid">Screen 4"</td></tr><tr>	<td class="message">Color</td>	<td data-convid="11" class="conversationid">Green</td>	<td data-convid="11" class="conversationid">Green</td>	<td data-convid="15" class="conversationid">Black</td></tr></table><br/><input type="button" id="btn1" value="Search for dups"></body>    </html>
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...