posted
I use dreamweaver to code, and I've always used the generic mouseover scripts that dreamweaver generates for you when doing mousevers. I'm playing around with php right now and have become stuck trying to get mouseovers to work properly the way i'm used to doing them. I'll only post the relevant code below.
the javascript for the mouseovers in the "head" tag:
code:
<script language="JavaScript"> <!-- function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 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];} } //--> </script>
So can I not use dreamweaver to create mouseovers for me if I'm going to be using php? Or is there something else specific to doing mouseovers in php that i'm not aware of? as in, does the javascript need to change at all?
I've tried a couple different things using alternate javascript and I can't seem to get any of it to work.
anyone?
Here's another way i tried with the same problem. when i put up the page and view the source, the image path in the js events is highlighted in red. this is the same thing that happens the first way i posted too.
posted
Post the generated HTML source when you view the page, that should allow me to determine the cause.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
posted
except php doesn't allow you to use double quotes. which is why i'm using single quotes for all of them.
Posts: 8741 | Registered: Apr 2001
| IP: Logged |
posted
OK, the problem is that every image needs to have a unique name and you are naming them all "Allentown" so it doesn't know which one to switch. You can fix this by:
adding this line immediately before the while statement: imageNum = 0;
replace the mouseOver with (I changed the function name just to post because it wouldn't let me write the real one: onMOver='MM_swapImage('Allentown$imageNum','','Images/allentown2.jpg',1)'>
and replacing the image tag with: <img src='" . $row['ImagePath'] . "' border='0' name='Allentown$imageNum'>
Adding this before the end of the while loop: $imageNum++;
I tried to just post the rewritten code but it wouldn't let me post HTML. I'd be happy to email it you though.
Posts: 159 | Registered: Jun 2006
| IP: Logged |
posted
Chanie: you can post code by using (code) (/code) tags, just with square brackets instead of parentheses.
Posts: 15770 | Registered: Dec 2001
| IP: Logged |
posted
hmmm...thanks Chanie. the frustrating thing abot all that is that originally I DID have the names in the code. and then somewhere in the process of trying to get at the root of the problem i lost them. stupid.
posted
I have a new question. I have some more lines of javascript code that aren't executing properly. here's the deal. the php generates the correct code. but when it generates the code it looks like this:
code:
var dynimages=new Array() dynimages[0]=["Images/Projects/Catasauqua/Big/CA002.jpg", " "]dynimages[1]=["Images/Projects/Catasauqua/Big/CA003.jpg", " "]dynimages[2]=["Images/Projects/Catasauqua/Big/CA001.jpg", " "]
the problem is that for the code to execute correctly it needs to have carriage returns in between each array declaration. as in:
I'm sure this is simple, but I don't know how to do it. How do I make it so that when the php generates the code, it generates each declaration on a new line?
Posts: 8741 | Registered: Apr 2001
| IP: Logged |
the newline escape code is exactly what I needed. couldn't seem to find that listed anywhere in any of the tutorials I have.
Posts: 8741 | Registered: Apr 2001
| IP: Logged |
posted
Also, you may want to use the other archaic code \r along with it. It's a unix (or maybe mac) versus windows thing, if I recall correctly. I always use both, like this: \r\n