Why does this NOT work

A

Aquosus

My Images are too large, so I will cut them way down

What is wrong with my code

snippet+++++++


var myImgs=document.getElementsByName("escoImg");
var numImgs=myImgs.length;

/* area of my question the below if statement */
if(myPtr)//true means previous button pushed
{
myImgs.reverse();//reverse the array does NOT WORK
}
//end of question area

for(var x=0;x<numImgs;x++)
{
if(myImgs[x].style.display=="block")
{
myImgs[x].style.display="none";
document.forms[2].elements[0].value=++x;
break;
}
}

if(document.forms[2].elements[0].value==myImgs.length)
document.forms[2].elements[0].value=0;

myImgs[document.forms[2].elements[0].value].style.display="block";

end snippet+++++++



it captures the correct elements. then if I want to hide the shown element
it works
I then can show the desired element.

But if I reverse the array BANG the hole thing dies WHY?

What is wrong with my code???
http://escokitchens.com/learning/kitcheView.html
 
E

Evertjan.

Aquosus wrote on 08 okt 2006 in comp.lang.javascript:
var myImgs=document.getElementsByName("escoImg");
[,,]

myImgs.reverse();//reverse the array does NOT WORK

You are wrong in your conclusion.
Did you read the errortext?

While you can reverse() an array,
the above is not an array but a collection of objects.
 
A

Aquosus

Evertjan. said:
Aquosus wrote on 08 okt 2006 in comp.lang.javascript:
var myImgs=document.getElementsByName("escoImg");
[,,]

myImgs.reverse();//reverse the array does NOT WORK

You are wrong in your conclusion.
Did you read the errortext?

While you can reverse() an array,
the above is not an array but a collection of objects.

I hate to admit it but I know very little about this stuff. I know C++ and
mySQL but not javascript. I will have to find where the errortext is
located.

Thanks

Warren
 
E

Evertjan.

Aquosus wrote on 09 okt 2006 in comp.lang.javascript:
I hate to admit it but I know very little about this stuff. I know C++
and mySQL but not javascript. I will have to find where the errortext
is located.

1 By clicking on the error icon in IE,
when the unfriendly "friendly errors" are switched off.

2 By reading thr error console in FF, I think.

Try:

======= test.html =======
<script type='text/javascript'>
replace(//,'')
</script>
=========================
 
K

Kevin Darling

Aquosus said:
I hate to admit it but I know very little about this stuff. I know C++ and
mySQL but not javascript. I will have to find where the errortext is
located.

When there's an error, IE displays a little yellow triangle warning in
the lower left of the browser window. Double-click it to see the
error. Be sure to click the Previous error button if it's enabled.

During development, you should leave the error reporting on. Under
IE's Tools menu, Internet Options - Advanced, Browsing section, check
"Display Notification about Every Script Error". and probably should
uncheck "Show friendly HTTP error messages". The latter change will
display whatever the server responds with, instead of the built-in IE
error screen. This can be handy while debugging.

Cheers, Kev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top