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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.getElementById("excelTable").rows[i].childNodes[0].innerText firefox

    i have an onclick function, but after debuging i found that firefox and only firefox blocks at the line

    " individualNames = names.childNodes[0].innerText; "
    is there somthin im missing please help.

    function searchForm()
    {
    var change = 0;
    var searchValue = document.getElementById("searchValue").value.toLowerCase();
    var count = document.getElementById("excelTable").rows.length;
    var once = true;
    myArray = new Array();

    if(searchValue == ""){alert("Please enter a value"); return false}

    for(i=0;i<=count;i++){

    names = document.getElementById("excelTable").rows[i];

    individualNames = names.childNodes[0].innerText;




    //only by last name of the file coming in format == "LastName, FirstName"
    lastName = individualNames.split(", ");
    //only by last name

    lowerCaseNames = lastName[0].toLowerCase();
    names.style.backgroundColor = "#FFF";

    if(lowerCaseNames.indexOf(searchValue) != -1)
    {
    names.style.backgroundColor = "#999";
    //make the first result with the search apear on screen than stop after the first
    if(once==true){document.getElementById("excelTable").rows[i].scrollIntoView(true); once=false;}


    myArray[change] = document.getElementById("excelTable").rows[i];//fill a passing array to next function
    change++;//make the array go to next slot

    document.getElementById("nextButton").disabled = false;

    document.getElementById("searchTitle").scrollIntoView(true);
    }
    }
    }

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    innerText is an Internet Explorer proprietary command. For cross browser support you should either use innerHTML or the appropriate DOM commands.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow easy fix, Thank you i didn't know that it was propreatary to IE but theoreticly if i had more children under that it would return the tags as well wich is unwanted if you want content, is the only solution is to parse everthing??

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,633
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by johnwhite11 View Post
    Wow easy fix, Thank you i didn't know that it was propreatary to IE but theoreticly if i had more children under that it would return the tags as well wich is unwanted if you want content, is the only solution is to parse everthing??
    JavaScript doesn't parse innerHTML content at all - it assumes that it is just plain text and ignores any tags in it. If you want JavaScript to be able to see the HTML tags within what you are adding you need to use the proper DOM commands to add them all separately as that is the only way that JavaScript will be able to reference the individual tags from its subsequent code.

    As an example - if you use innerHTML to add a <div id='x'> tag to the page you cannot then reference it using getElementById('x') because JavaScript doesn't see that as a tag. You'd need to use createElement to create the tag, then add the id to it and then use appendChild to add it to the page in order to be able to reference the id in later JavaScript.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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