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 to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Filtering children object from parent

    Hi mates,

    As I'm newbie integrating PHP-HTML-JS I'd need some help for doing the following:

    I have a index.php including:

    <script type="text/javascript">
    function filter (phrase, _id){
    var words = phrase.value.toLowerCase().split(" ");
    var table = document.getElementById(_id);
    var ele;
    for (var r = 1; r < table.rows.length; r++){
    ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
    var displayStyle = 'none';
    for (var i = 0; i < words.length; i++) {
    if (ele.toLowerCase().indexOf(words[i])>=0)
    displayStyle = '';
    else {
    displayStyle = 'none';
    break;
    }
    }
    table.rows[r].style.display = displayStyle;
    }
    }
    </script>


    <div id="filter">
    <form>
    <input name="filt" onkeyup="filter(this, 'LIST', '1')" type="text">
    </form>

    <div id='iframe01'> <iframe src='child.php' name='iframe01'></iframe>
    </div>

    and a child.php including a table object with the id LIST.

    I'd need to change the parent.php in order to filter on real-time the table LIST via the FILT input on the parent form. I have tried different values instead of 'this' on the js function calling but nothing succesfully. ¿Any ideas?
    Thanks so much

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,342
    Thanks
    13
    Thanked 349 Times in 345 Posts
    two things, you don’t have a parent form (the only child in the form is the text field). second, you want to access an iframe which is a completely new document. (and because I don’t use frames, I have forgotten how to access them through JavaScript). the this has to stay there, as it grants you access to the text field’s value.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanxs, hope to read more ideas


  •  

    Tags for this Thread

    Posting Permissions

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