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;
";
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to