javascript error in Netbeans

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
Hi
I'm getting these error for this function in Netbeans, What am I missing here?

missing ; after for loop
missing ; before statement

function MM_swapImage() {
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Your problem is you're using Dreamweaver. ;)

Test in FireFox and check what the Error Console says, usually gives a much better description of the error than IE.
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
Shot, yeah code is generated from Dreamweaver. Only now (for the last week actually) with trying to get a php mysql guestbook script into the website have had to go with Netbeans to see what's going on with it. Do have xdebug setup on the local wamp server.

Strange thing when I added <php? tag the errors dissapeared,
<script language="JavaScript" type="text/JavaScript"> is in place.

I've got some hair pulling to do with this one that's for sure.
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
mozilla has "pretty print" if this makes it easier to read, still can't see why netbeans is picking up an issue with just this one function though.

Code:
function MM_swapImage() {
         var i, j = 0, x, a = MM_swapImage.arguments;
         document.MM_sr = new Array();
         for (i = 0; i < (a.length - 2); i += 3) {
             if ((x = MM_findObj(a[i])) != null) {
                 document.MM_sr[j++] = x;
                 if (!x.oSrc) {
                     x.oSrc = x.src;
                 }
                 x.src = a[i + 2];
             }
         }
     }
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Try

Code:
function MM_swapImage() {
         var i, j = 0, x, a = MM_swapImage.arguments;
         document.MM_sr = new Array();
         for (i = 0; i < (a.length - 2); i += 3[b][color=red];[/color][/b]) {
             if ((x = MM_findObj(a[i])) != null) {
                 document.MM_sr[j++] = x;
                 if (!x.oSrc) {
                     x.oSrc = x.src;
                 }
                 x.src = a[i + 2];
             }
         }
     }

If I were you I'd kick Dreamweaver aside and go with jQuery (and learn some nice JavaScript). Image Mouseover is literally 1 line of code and easy to understand
 

Raithlin

Executive Member
Joined
Jan 4, 2005
Messages
5,049
I do this using CSS - much better than using Javascript, and quicker if you use CSS sprites.

I had this error before going that way, btw. I'm maintaining a site that was written using this, and there was an error in Mozilla that can be fixed by adding one line of code. Google for it if you think that's the issue.
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
Thanks,

tried that now > i += 3; same error still, so think Netbeans' confused (me) somewhere :p

Yeah it's an old dreamweaver and I'm not bothered too much with updating it, just using it for layout to get some sort of website up in a hurry. Will grab jQuery now. shot
 

FarligOpptreden

Executive Member
Joined
Mar 5, 2007
Messages
5,396
I do this using CSS - much better than using Javascript, and quicker if you use CSS sprites.
+1. CSS is much better at doing mouse-over image swap-outs. It also keeps the HTML clean and you're not dependent on the client browser's JS being active.
 

Raithlin

Executive Member
Joined
Jan 4, 2005
Messages
5,049
np. I see Netbeans 6.7 is out too. Downloaded it last night. Er, wanted to, though it would be easier to update 6.5... :erm:
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
+1. CSS is much better at doing mouse-over image swap-outs. It also keeps the HTML clean and you're not dependent on the client browser's JS being active.

Shot. I'll keep that in mind, for now the js function is working (only netbeans say's it shouldn't be) I will get back to the CSS mouse-over way of doing things though, looks like much cleaner and powerfull code to what dreamweaver spews out.

All this mission for a guestbook php script -
Free PHP VX Guestbook which uses MiniTemplator.
 

Drake2007

Expert Member
Joined
Oct 23, 2008
Messages
4,413
Thanks guys for all your input, Very good advice.

I got the last minute website up and running so I've had some time to get most of this going through learning curve etc. Thanks Raithlin & Farlig, CSS sprite's for navigation works like a dream.

Any complete CSS references out there? And maybe Ajax if it get's that more interesting, not a priority ATM. AcidRazor, All I can say is I'll never use tables or dreamweaver again will still keep that jQuery in mind when it comes to that.

Shot
 

dequadin

Expert Member
Joined
May 9, 2008
Messages
1,434
Thanks guys for all your input, Very good advice.

I got the last minute website up and running so I've had some time to get most of this going through learning curve etc. Thanks Raithlin & Farlig, CSS sprite's for navigation works like a dream.

Any complete CSS references out there? And maybe Ajax if it get's that more interesting, not a priority ATM. AcidRazor, All I can say is I'll never use tables or dreamweaver again will still keep that jQuery in mind when it comes to that.

Shot

w3schools?
 
Top