Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
11-16-2010, 04:38 PM #1
- Join Date
- Nov 2010
- Thanked 0 Times in 0 Posts
I want to make a function but I can't get hold of the right stuff to do. That's why I ask for your help!
So I have got a <div> with many hidden <p>s. I want to make my script so that when a form input (text) is being written by the user (so onKeyUp), it reveals those paragraphs which have got the kind of text in them that's in the form input box.
So for example:
- the box is empty -> all paragraphs are hidden
- the box has got "are" in it -> the script (or the function) searches the paragraph for the word "are" and shows those whcih have got it in them.
I know how to make a paragrah hidden and visible, I also know how to set up the event with the form box to call the function...
My problem is that I don't know how to et up the search in the particular paragraphs and how to get their ID perhaps... Once I had their ID I could make them visible.
So my question is... Is there a way to search text in particular paragrah and if the search positive get their IDs? Or is it possible to search for IDs?
11-16-2010, 06:41 PM #2
- Join Date
- Jun 2002
- London, England
- Thanked 2,542 Times in 2,520 Posts
It is quite remarkable how beginners always seem to want the oddest and most outlandish things.
I see many problems here. The user types "a" and all the paras containing the letter a (such as along) are revealed. He then types "r", and at once all those paras which do not contain "ar" are hidden again.
And do you mean whole words or embedded words? If I type "fat" do I get "father"? Which is then hidden again when I go on to type "fatter"? Sounds a total mess to me.
I think you should think this through and ask yourself why you want to do this. It will certainly drive people away from your site. If you are trying to devise some sort of search feature, then that should be done server-side.
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
Last edited by Philip M; 11-16-2010 at 06:46 PM. Reason: Correction
11-16-2010, 07:14 PM #3
FWIW, if you still MUST do what you described, it's nearly trivial.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
11-16-2010, 07:19 PM #4
- Join Date
- Mar 2009
- Portland Oregon
- Thanked 63 Times in 62 Posts