Thread: I need help with a search table!
Results 1 to 4 of 4
Related
-
search bar Forum: HTML Forum
Replies: 1 -
How can you make a table border on only one side of the table? Forum: HTML Forum
Replies: 5 -
SEARCH script not aligning in table correctly Forum: Website Scripts Forum
Replies: 4 -
search engine that pay Forum: Webmaster Ethics
Replies: 1
-
03-17-2009, 04:43 PM #1
I need help with a search table!
I would like to make (by myself, no "auto generate" sites, please- I want to learn) a table where I can search within it. For instance, If I have a table that has open fields, I can put "000|245|255" and it would come up with the RGB code for it, and also the closest codes within, say, 25 points.
Like this:
"Search" 000|245|255
"Found" 10pts form Pure Cyan (000|255|255)
Where could I find the resources to research and find coding for something like that?
Thank You!
~~Kitty~~
-
03-17-2009, 11:16 PM #2
Re: I need help with a search table!
I understand wanting to do this on your own. How else do you learn, right? So are you wanting to learn Javascript, or a server-side scripting language such as PHP or ASP?
How are you determining the values that go in the table in the first place?
The simplest way to do it (whatever language you use) is to store the values you are putting in the table in an array and search through the array as needed.
-
03-18-2009, 01:48 AM #3
Re: I need help with a search table!
Well, I keep seeing PHP, so I think that's it. Um, as far as the table, I made one in Microsoft Works Datasheet and it's good and all to manually look through my lists but it really bites when I have to find a "similar" value, such as in my first post. I am attempting to make an actual html table with all of the values in it, I would like to know if I can use a search engine of sorts to make it easier...
Thank You jthane!
-
03-24-2009, 12:51 PM #4
Re: I need help with a search table!
So, you want to find out, given Red, Green, Blue values, what's the name of a color that's closest to these values.
Very good idea. I recommend learing some scripting language.
Here is a suggestion about how to do this.
Store the file that you have created of colors in .CSV format, at, say, C:/colors.csv. I will assume the file has the following format.
Red,255,0,0
Green,0,255,0
Blue,0,0,255
Pure Cyan,000,255,255
...
Code:# SCRIPT ClosestColor # Input arguments var int inR, inG, inB set $wsep = "," var int shortest, distance var str output # Go thru the color list, find the color that is the closest. # We will set $shortest to the highest value possible set $shortest = 256+256+256 var str colors ; cat "C:/colors.csv" > $colors while ($colors <> "") do var str color ; lex -e "1" $colors > $color var str name ; var int R, G, B set $name = { wex -e -p "1" $color } set $R = makeint(str({wex -e -p "2" $color})) set $G = makeint(str({wex -e -p "3" $color})) set $B = makeint(str({wex -e -p "4" $color})) var int distanceR, distanceG, distanceB set $distanceR = ($R-$inR) if ($distanceR < 0) set $distanceR = -1 * $distanceR endif set $distanceG = ($G-$inG) if ($distanceG < 0) set $distanceG = -1 * $distanceG endif set $distanceB = ($B-$inB) if ($distanceB < 0) set $distanceB = -1 * $distanceB endif set $distance = $distanceR+$distanceG+$distanceB if ($distance < $shortest) do set $shortest = $distance set $output = $name done endif done # The closest color name is in $output. echo $output
script ClosestColor.txt R(0) G(255) B(0)
The above should produce "Green".
I have tested this script.
You can even run this script as part of your web site. If you don't have biterscripting, download free at
http://www.biterscripting.com/install.html
Richard