Jump to content

PHP and Javascript problem.


CrAzEd
 Share

Recommended Posts

When you're defining the new images with new Image(), what is with the arguments? You don't need 100,45 from what I know...in fact, I didn't even know the new Image function had arguments! :)

Link to comment
Share on other sites

Perhaps there is a problem with javascript and php? it worked perfectly before i added the php, and the code hasnt changed. Im using a system for the main text section, using

[code]<?php 	   if ($_GET['v'] == '') { 		$page = "phpbody/home.php"; 	} 	elseif ($_GET['v'] == '1') { 		$page = "phpbody/contact.php"; 	} 	elseif ($_GET['v'] == '2') { 		$page = "phpbody/limousines.php"; 	} 	   elseif ($_GET['v'] == '3') { 		$page = "phpbody/about.php"; 	} 	elseif ($_GET['v'] == '4') { 		$page = "phpbody/sthummer.php"; 	} 	elseif ($_GET['v'] == '5') { 		$page = "phpbody/suv.php";	} 	elseif ($_GET['v'] == '6') { 		$page = "phpbody/bmw.php";	} 	elseif ($_GET['v'] == '7') { 		$page = "phpbody/hummerh2.php"; 	}  	elseif ($_GET['v'] == '8') { 		$page = "phpbody/gallery.php"; 	} ?>

in the head, and this

<?php include ("$page"); ?>

to add the page. I hope you understand what i mean. Here is an example of the javascript. -

if (document.images)   {	 pic1on= new Image();	 pic1on.src="images/limousines_over.gif";  	 pic1off= new Image();	 pic1off.src="images/limousines_up.gif";   }

Those link to the images, and this is the load/unload -

function lightup(imgName) {   if (document.images)	{	  imgOn=eval(imgName + "on.src");	  document[imgName].src= imgOn;	} }function turnoff(imgName) {   if (document.images);	{	  imgOff=eval(imgName + "off.src");	  document[imgName].src= imgOff;	}										 }

As i said before, this worked perfectly before i added the php above.

Link to comment
Share on other sites

Well, first of all, have you tried using the "switch" statement in php? It's a bit more orderly than using a couple of ifs/elseifs. Here's your code in switch:

switch($_GET['v']) {  case '' {		$page = "phpbody/home.php";   }  case '1' {		$page = "phpbody/contact.php";   }  case '2' {		$page = "phpbody/limousines.php";   }  case '3' {		$page = "phpbody/about.php";   }  case '4' {		$page = "phpbody/sthummer.php";   }  case '5' {		$page = "phpbody/suv.php";   }  case '6' {		$page = "phpbody/bmw.php";   }  case '7' {		$page = "phpbody/hummerh2.php";   }  case '8' {		$page = "phpbody/gallery.php";   } }

See if that works?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...