TRname =
rowelements[tnindex].childNodes[1].childNodes[1].childNodes[0].nodeValue;
MHO =
rowelements[mhoindex].childNodes[13].childNodes[1].childNodes[0].nodeValue;
if(MHO=='something')
{
var url='http://some.link';
}
else if(MHO=='smthelse')
{
var url='http://some.other.link';
}
var newlink=document.createElement('a');
newlink.target = '_blank';
newlink.innerHTML='>>';
newlink.href=url+TRname;
rowelements[tnindex].childNodes[1].appendChild(newlink);
}
The problem is that when I want to test the value of the MHO variable
in the if statements, its value is undefined. I thought that I should
have no scope problems, but there it is. Anyone have any idea?
Thanks,
Tamas
I don't think you have a scope problem. It may be that you are trying
to get .nodeValue from some object where it is undefined. E.g;
('abc'.nodeValue == undefined)
The thing is, that I checked before, and just before the if statement,
the MHO variable has the correct value, and is NOT undefined.
Any ideas?
BR,
Tamas
--
May the road rise to meet you.
May the wind be always at your back.
May the sun shine warm upon your face.
May the rains fall soft upon your fields.
And until we meet again,
May God hold you in the hollow of His hand.
(Irish blessing)
nMHO =
rowelements[mhoindex].childNodes[13].childNodes[1].childNodes[0];
alert(nMHO + '\n' + nMHO.nodeValue);
where "value" is exactly what I expect to be its value.
On 5/3/07, RodMcguire <mcg...@telerama.com> wrote:
>
>
Unless there's a specifically good reason not to, it's always much
better, when asking for help, to give the WHOLE script, and the WHOLE
page it is being applied to. For reada- and usa-bility, links for both
are often best.
That should be your problem. So either your mhoindex value is incorrect
and/or being calculated out of bounds, or your line of reference from
childNodes[13].... is undefined somewhere.
--
Which conspiracy theory do you believe?
The Government's Official Conspiracy Theory Story,
or one of the alternative conspiracy theories?
Demand Truth and Justice! http://www.Chico911Truth.org/
On May 3, 11:10 am, "kenez.ta...@gmail.com" <kenez.ta...@gmail.com>
wrote:
> rowelements[tnindex].childNodes[1].appendChild(newlink);
if I understand your script right you are skipping rows in a table.
The way you coded it you will most likely ending with:
i < TRno && 8+i*6 > TRno
What means that for one of your last iterations your calculated offset
"mhoindex" will be bigger then TRno. Given that TRno is the maximum
number of rows in the table accessing that row will fail.
If you work with tables you may want to take a look at the rows and
cells properties.
cell = table.rows[i].cells[j];
if(cell.textContent.match(/awfull/)){
}
As you seen by all those replies ppl have a hard time to understand
your code. Even as you (seam to) do something quite basic like walking
over a table. For my eyes your coding style is rubbish. You could
start to do better by changing i=i+1 to i++.
If the web page you want to grease is on the WWW a link to sayed page
with maybe a hint to what element you want to change will always be a
good idea.
I think your problem is here. url is defined as a variable inside the
if block (and the else block as a separate variable...
> }
> else if(MHO=='smthelse')
> {
> var url='http://some.other.link';
... here).
> }
>
>
> var newlink=document.createElement('a');
> newlink.target = '_blank';
> newlink.innerHTML='>>';
> newlink.href=url+TRname;
Then you try to use it here when it's out of scope.
If this snippet is representative of the real script, you should
change it to something like the following:
var url;
if(MHO=='something')
{
url='http://some.link';
}
else if(MHO=='smthelse')
{
url='http://some.other.link';
}
If this isn't the problem, as someone else requested you need to
include the full code and a URL that you're trying to use it on.
HTH
Hwyl,
Neil.
I think your problem is here. url is defined as a variable inside the
if block (and the else block as a separate variable...
Then you try to use it here when it's out of scope.
It finally works! The thing that fixed it was modifying the check
condition in the if's from MHO=='something' to
MHO.textContent.match('something'). It still puzzles me how this
solved it, but the important thing is that it works. Thanks again for
all your help,
BR,
Tamas