hegerp
11-16-2010, 04:38 PM
Hi,
I'm quite new to Javascript but I decided to learn it.
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 "a" in it -> the javascript searches all paragraphs and makes those visible which paragraphs have the letter 'a' in them anywhere, and leaves the other paragraphs 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?
I'm quite new to Javascript but I decided to learn it.
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 "a" in it -> the javascript searches all paragraphs and makes those visible which paragraphs have the letter 'a' in them anywhere, and leaves the other paragraphs 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?