/    Sign up×
Community /Pin to ProfileBookmark

Search engine in table cells

Hi, I have been looking for a script that can search,
but instead of searching words, I want it to search for a ID in a table cell, and if it finds a matching id in that cell, that cell will highlight in a color of my own choose. That is that the site don’t have to refresh, just color the cell if it finds one matching

Just in case, if there aren’t any in js/dhtml MySQL databases is fine to me. ?

Thank you,
ReVarre

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@BigMoosieSep 27.2005 — [B]document.getElementById("cellID").style.backgroundColor="green";[/B]

If you want to search other files then you will need to use server side scripting.
Copy linkTweet thisAlerts:
@ReVarreauthorSep 27.2005 — [B]document.getElementById("cellID").style.backgroundColor="green";[/B]

If you want to search other files then you will need to use server side scripting.[/QUOTE]


I'm sorry, but I'm not good at javascript, and just to be sure..

I want the users to be able to apply any number at all, and if it isn't in the document it will come up in a basic windows error window and says "no results", whilst if you type a correct number it will highlight the square with the matching ID, that is there will be about 2900ID's to choose between so... ?

Also if it's possible to.. When it find a result, can it go down to a supplied anchor bound to that ID?
Copy linkTweet thisAlerts:
@BigMoosieSep 27.2005 — I can't remember the necessary cross-browser codes to scroll it into view off the top of my head.


function findId(x){
var y = document.getElementById(x);
if (y) {
y.style.backgroundColor="green";
}
else {
alert("No result for " + x + ".");
}
}
Copy linkTweet thisAlerts:
@ReVarreauthorSep 27.2005 — It's nice to get fast responds, but how do I test this script using a form code?

Never been into search engines or forms much before so I don't know how to put it in, only know the from tags and how to make the textfield and button. ?

EDIT;
[CODE]<HTML><HEAD><script language="javascript" type="text/javascript">
function findId(x){
var y = document.getElementById(x);
if (y) {
y.style.backgroundColor="green";
}
else {
alert("No result for " + x + ".");
}
}
</script></HEAD><BODY><FORM ACTION="findit()">
<P align="center">Search for:

<INPUT TYPE="TEXT" NAME="SearchString" SIZE="30">
<INPUT TYPE="SUBMIT" VALUE="Search Now">
</P>
</FORM></BODY></HTML>[/CODE]
Copy linkTweet thisAlerts:
@BigMoosieSep 28.2005 — This seems to be just about everything, you might want to use document.write() to write the form to the page so people without javaScript enabled won't be hassled with a feature that doesn't work.

&lt;HTML&gt;&lt;HEAD&gt;&lt;script language="javascript" type="text/javascript"&gt;
var oldSearch=false;
function findId(x){
if (oldSearch) oldSearch.style.backgroundColor="";
var y = document.getElementById(x);
if (y &amp;&amp; y.tagName.toLowerCase()=="td") {
y.style.backgroundColor="lime";
oldSearch=y;
y.scrollIntoView();
}
else {
alert("No result for " + x + ".");
oldSearch=false;
}
}
&lt;/script&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;FORM ACTION="#" onsubmit="findId(this.SearchString.value);return false"&gt;
&lt;P align="center"&gt;Search for: <br/>
&lt;INPUT TYPE="TEXT" NAME="SearchString" SIZE="30"&gt;
&lt;INPUT TYPE="SUBMIT" VALUE="Search Now"&gt;
&lt;/P&gt;
&lt;/FORM&gt;&lt;/BODY&gt;
Copy linkTweet thisAlerts:
@ReVarreauthorSep 28.2005 — I don't know how to thank you, my gratitude is to big to describe.

All I can say is, it worked, your the best, THANKS!!!

Hooray for you people who are helping people in this kind of way, your simply the best!

Thanks again, and again... I have looked for this for a loooong time,

ReV
Copy linkTweet thisAlerts:
@BigMoosieSep 28.2005 — Glad to be of help, its nice to see such appreciation.
×

Success!

Help @ReVarre spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...