#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Need Help for onmouseover in PHP


    I am bringing four pictures from the database and want to show the name when the mouse is moved over to the picture using onmouseover.

    This is my javascript:

    <script>

    function showcontact(element)
    {
    var contactdiv = document.getElementById('contactdiv');



    x = element.offsetLeft;
    y = element.offsetTop;

    contactdiv.style.left = x + 170;
    contactdiv.style.top = y + 30;

    contactdiv.style.visibility = 'visible';
    }


    function hidecontact()
    {
    var contactdiv = document.getElementById('contactdiv');
    contactdiv.style.visibility = 'hidden';
    }


    </script>


    and in my PHP program:

    print "<p><img src='images/".$image_file."' onMouseOver = showcontact('this','".$lastname."') onmouseout = hidecontact(this)>";

    It would be great if anyone can help me out ....
    Code:
    code
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    Is there any particular thing you need help with? I don't see a question or an error message. Do you debug JS in firebug or chrome debugger?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by ManiacDan
    Is there any particular thing you need help with? I don't see a question or an error message. Do you debug JS in firebug or chrome debugger?

    I want to show name, phone and email when someone moves the mouse over the picture. I dont how to do that. I am new to Javascript. Below is my complete program.
    Code:
    <HTML>
      <HEAD>
        <TITLE> KINGS WEBSITE </TITLE>
        <link rel = "stylesheet" type="text/css" href="css/basic_004.css" />
    
        <style>
    		#contactdiv
    		{
    			position: absolute;
    			left: 100px;
    			top: 100px;
    			width: 100px:
    			height: 20px;
    			padding: 5px;
    			background-color: red;
    			visibility: hidden;
    		}
    
    	</style>
    
    
        <script>
    
       function showcontact(element)
    	{
    				var contactdiv = document.getElementById('contactdiv');
    
    
    
    				x = element.offsetLeft;
    				y = element.offsetTop;
    
    				contactdiv.style.left = x + 170;
    				contactdiv.style.top = y + 30;
    
    				contactdiv.style.visibility = 'visible';
    			}
    
    
    			function hidecontact()
    			{
    				var contactdiv = document.getElementById('contactdiv');
    				contactdiv.style.visibility = 'hidden';
    			}
    
    
           </script>
      </HEAD>
    
      <body>
    
      <!-- Adding Image  -->
    
    	  <img src = "KingLogo.jpg" width ="576" height= "87">
    
     <div id = "FeatureHouse">
    
      <?php
       print " <p><strong><h3> Featured Home! </strong> </h3> </p>";
    
      	     print "<p><img src='/images/house_mallard_1.jpg'></p>\n";
      	     print "<p> <h3> <strong> Won't last long at this price! </p> </h3> </strong>";
      	     print "<p> <br /> Enjoy the quiet in this Mallard Manor home.
                        Lovely garden views and a short walk to the
                        golf course for those who can't get enough
                        of green living.
                    <p>";
    
         ?>
       </div>
    
        <div id = "findCity">
    	   <Form method = "Post" action="Assignment_8_HouseList.php">
    	   Enter City:
    	              <input type = " text" name="findCity" size="30">
    
    	     <p> (Leave blank to find all houses listed) </p>
    
    	              <input type = "Submit" value = "Find City">
    
    	    <p> Note: We represent homes in the following cities: OceanCove, Tomsville, Pine Beach  </p>
      </div>
    <!--  <div id="validusers">
        </div>
    
        <div id="errordiv" style="color: red;">
    </div>  -->
    
    <!  *********************************  -->
    <!   Displaying Realtors List          -->
    <!   *********************************   -->
    
    
    <div id = "calculator">
        <?php
    
    			 include 'Assignment_8_Using_common_functions.php';
    
    			 	displayRealtors();
    
    			 ?>
    
     </div>
    
    
    <div id="endpage">
    			 	<br /><br /><br /><br />
    </div>
    
     <?php
    			 function displayRealtors()
    			 {
    			 	$statement  = "SELECT lastname, firstname, phone, email, image_file ";
    			 	$statement .= "FROM s1583_realtor ";
    			 	$statement .= "ORDER BY firstname ";
    
    
    
    			 	$sqlResults = selectResults($statement);
    
    			 	$error_or_rows = $sqlResults[0];
    
    			 	if (substr($error_or_rows, 0 , 5) == 'ERROR')
    			 	{
    			 		print "<br />Error on DB";
    			 		print $error_or_rows;
    			 	}
    			 	else
    			 	{
    
    			 		$arraySize = $error_or_rows;
    
    			 		for ($i=1; $i <= $error_or_rows; $i++)
    			 		{
    			 		    $lastname = $sqlResults[$i]['lastname'];
    			 			$firstname = $sqlResults[$i]['firstname'];
    			 			$phone = $sqlResults[$i]['phone'];
    						$email = $sqlResults[$i]['email'];
    			 			$image_file = $sqlResults[$i]['image_file'];
    
    			 			$fullName = "$firstname $lastname";
    
    
    			 			 print "<p><img src='images/".$image_file."' onMouseOver = showcontact('this','".$lastname."') onmouseout = hidecontact(this)>";
    			 			 print "<br />".$firstname."</p>\n";
    
    
    			 	     }
    
    
    
    
    
    
    				}
    
    
    		}
    
    	     ?>
    <div id = "contactdiv">
    </div>
    
    <div id="footer">
     <p> <a href = " Assignment_8_GuestBook_Form.php "> View Guestbook </a>  /
          <a href = " Assignment_8_CalculateMortgage.php "> Calculate Mortgage </a>
         </p>
    
     </div>
    
    </body>
    </HTML>
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,853
    Rep Power
    6351
    I've moved your thread to the javascript forum. Get this working without PHP first.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo