Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-16-2012, 07:08 PM   PM User | #1
johnwhite11
New to the CF scene

 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
johnwhite11 is an unknown quantity at this point
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);
}
}
}
johnwhite11 is offline   Reply With Quote
Old 01-16-2012, 07:58 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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/
felgall is offline   Reply With Quote
Old 01-16-2012, 08:13 PM   PM User | #3
johnwhite11
New to the CF scene

 
Join Date: Dec 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
johnwhite11 is an unknown quantity at this point
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??
johnwhite11 is offline   Reply With Quote
Old 01-17-2012, 08:27 AM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
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/
felgall is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:28 AM.


Advertisement
Log in to turn off these ads.