Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to search the given text in the particular <div> tag..

    hi
    my requirement is to search for the text available in the table, the table is inside the <div>, not in the entire web page.
    <div>
    <table>
    </table>
    </div>

    how can i acheive this...

    once the search result is found in the table..., i want the subsequent search for the same criteria to be made using a shortcut key..
    ex:

    i am having a text box for the search criteria...
    and a search button to search the entered criteria...

    first the user enters the search criteria in the text box and then clicks on the search button...., now if the search is found, then the particular text is highlighted....and i want to have a short cut key....after pressing that key...the subsequent search should be made...for the same given criteria...


    thnx
    murali

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,859
    Thanks
    22
    Thanked 157 Times in 148 Posts
    what is the DOM structure of your table? Is it relatively simple -- i.e.:

    Code:
    <table id="data">
        <tr>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</p>
            </td>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</p>
            </td>
        </tr>
        <tr>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</p>
            </td>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</p>
            </td>
        </tr>
    </table>
    where each <p> tag is uninterrupted by further child nodes (again, for example)....

    Or is it more like this:

    Code:
    <table id="data">
        <tr>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. <b>Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum</b> sem non odio.</p>
            </td>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. <span style="color:red">Morbi auctor, sapien ut posuere porta, magna nisl tempus leo</span>, ut dictum ipsum sem non odio.</p>
            </td>
        </tr>
        <tr>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. <img src="picture.jpg" alt="a picture" /> Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</p>
            </td>
            <td>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis suscipit ultricies tortor. <b><i>Morbi auctor, sapien ut posuere porta, magna nisl tempus leo, ut dictum ipsum sem non odio.</i></b></p>
            </td>
        </tr>
    </table>
    where each <p> tag is interrupted by further child nodes....

    The latter version is much harder to traverse, either with the DOM or regular expressions, using Javascript (at least for me)...

    With PHP, I could do this a lot easier, because the regex functions seem more powerful to me (regardless of the complexity of the table's DOM structure)....

    Do you have to use all Javascript for this?..I think I might use some AJAX to to send the table's innerHTML to a PHP script, use some regex there (to create the text highlighting), and then send the innerHTML back to your javascript to be reinserted into the DOM...And keep doing that every time the shortcut key is pressed thereafter...
    Last edited by chump2877; 02-13-2007 at 01:59 PM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here in my case the <p> tag is uninterrupted.

    i am not very sure wheather i can use AJAX...,i should ask my TL n check...
    can u give me the code to acheive this using ajax as u told.....


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •