Re: menu mouseover using php and javascript
| From: | Marek Kilimajer | Date: | Wed, 22 Sep 2004 21:20:20 +0000 |
| Subject: | Re: menu mouseover using php and javascript | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197628@lists.php.net to get a copy of this message | ||
web_singer wrote:
I am using an array to create a menu and the code to change an image on mouseover. I would also like to change some text on mouseover. While i can do it using a swtich in javascript it requires that I hard code all the different options in. My whole reason for using the php in the first place was to avoid having to hard code anything at all. Does anyone have an idea how I can get the text portion to also use my variable?
function changeImages() { if (document.images) {for (var i=0; i<changeImages.arguments.length; i+=2) { document[changeImages.arguments[i]].src =eval(changeImages.arguments[i+1] + ".src");var getNum = changeImages.arguments[i+1];var getNum = getNum.substring(10); switch (getNum) { case "1" : var displayMe = text1;break;case "2" : var displayMe = text2;break;case "3" : var displayMe = text3;break; default : var displayMe = "Default text before mouseover";} change(document.getElementById('theSPAN'),displayMe);}} }
?> So while this works it requires that I add a new case to the switch for every additional menu item which makes the point of generating it in the first place mute. Any help would be appreciated.output the switch statements using php: foreach($texts as $case => $text) { echo " case '$case':
var displayMe = '$text';
break;
";
}