Jump to content

[SOLVED] Getting value from a onmouseover on a image


Hughesy1986

Recommended Posts

Hi Guys,

 

I am writing a ajax application which gets the user info from hover on the user image, now i have it all working except for the value being sent from the onmouseover, i am new to ajax so please be gentle LOL.

 

Heres the code.

 

<script type="text/javascript">
function getuser(){
var ajaxRequest;  // The variable that makes Ajax possible!

try{
	// Opera 8.0+, Firefox, Safari
	ajaxRequest = new XMLHttpRequest();
} catch (e){
	// Internet Explorer Browsers
	try{
		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try{
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e){
			// Something went wrong
			alert("Your browser broke!");
			return false;
		}
	}
}
ajaxRequest.onreadystatechange = function(){
	if(ajaxRequest.readyState == 3)
		{
		player.innerHTML = "<img src='loading.gif'/>";
		}
	if(ajaxRequest.readyState == 4){
		var player = document.getElementById('player');
		player.innerHTML = ajaxRequest.responseText;
	}
}
var member_id = document.getElementById('member').value;
var queryString = "?id=9";
ajaxRequest.open("GET", "roster.php" + queryString, true);
ajaxRequest.send(null);

}
</script>
<?php
/* 
**Roster processor
*/
/** SECURITY MOD **/
//(!defined('IN_SCRIPT') ? exit(0) : null);
//*****//

include("config.php");
if (!$_GET['id'])
{

$result = mysql_query("SELECT * FROM members ORDER BY rand()") or die (mysql_error());
$total = mysql_num_rows($result);

$lim = 8;

$i = 0;

while ($i < $total and $i < $lim)
	{
	$username = mysql_result($result, $i, 'username');
	$member_id = mysql_result($result, $i, 'id');
	$avatar = mysql_result($result, $i, 'avatar_link');

	if (!$avatar || empty($avatar))
		{
		$avatar = "images/roster_image.jpg";
	}
?>
<img src="<?php echo $avatar; ?>" alt="<?php echo $username; ?>" id="member" width="48" height="53" onMouseOver="getuser('<?php echo $member_id; ?>')" value="<?php echo $member_id; ?>"/>&nbsp
<?php
$i++;
}
}
if ($_GET['id'])
{
$id = clean($_GET['id']);
if (!$id || empty($id))
	{
	echo "Error with the id";
}else{
$result = mysql_query("SELECT * FROM members WHERE id = '$id'") or die (mysql_error());
$row = @mysql_fetch_array($result);
if (!$row)
	{
	echo "cannot find member";
	}else{
$username = $row['username'];
$location = $row['location'];
$game = $row['game'];
	// get the users flag

if ($location == "dontknow") {
$flag = "uploads/flags/unknown.gif";
}
if ($location == "usa") {
$flag = "uploads/flags/um.gif";
}
if ($location == "argentina") {
$flag = "uploads/flags/ar.gif";
}
if ($location == "australia") {
$flag = "uploads/flags/au.gif";
}
if ($location == "belgium") {
$flag = "uploads/flags/be.gif";
}
if ($location == "brazil") {
$flag = "uploads/flags/br.gif";
}
if ($location == "canada") {
$flag = "uploads/flags/ca.gif";
}
if ($location == "china") {
$flag = "uploads/flags/cn.gif";
}
if ($location == "croatia") {
$flag = "uploads/flags/cr.gif";
}
if ($location == "czech_republic") {
$flag = "uploads/flags/cz.gif";
}
if ($location == "denmark") {
$flag = "uploads/flags/dk.gif";
}
if ($location == "england") {
$flag = "uploads/flags/england.gif";
}
if ($location == "france") {
$flag = "uploads/flags/fr.gif";
}
if ($location == "finland") {
$flag = "uploads/flags/fi.gif";
}
if ($location == "germany") {
$flag = "uploads/flags/de.gif";
}
if ($location == "greece") {
$flag = "uploads/flags/gr.gif";
}
if ($location == "india") {
$flag = "uploads/flags/in.gif";
}
if ($location == "iran") {
$flag = "uploads/flags/ir.gif";
}
if ($location == "iraq") {
$flag = "uploads/flags/iq.gif";
}
if ($location == "ireland") {
$flag = "uploads/flags/ie.gif";
}
if ($location == "israel") {
$flag = "uploads/flags/il.gif";
}
if ($location == "italy") {
$flag = "uploads/flags/it.gif";
}
if ($location == "jamaica") {
$flag = "uploads/flags/jm.gif";
}
if ($location == "japan") {
$flag = "uploads/flags/jp.gif";
}
if ($location == "mexico") {
$flag = "uploads/flags/mx.gif";
}
if ($location == "netherlands") {
$flag = "uploads/flags/nl.gif";
}
if ($location == "newzealand") {
$flag = "uploads/flags/nz.gif";
}
if ($location == "northkorea") {
$flag = "uploads/flags/nc.gif";
}
if ($location == "norway") {
$flag = "uploads/flags/no.gif";
}
if ($location == "pakistan") {
$flag = "uploads/flags/pk.gif";
}
if ($location == "poland") {
$flag = "uploads/flags/pl.gif";
}
if ($location == "portugal") {
$flag = "uploads/flags/pt.gif";
}
if ($location == "romania") {
$flag = "uploads/flags/ro.gif";
}
if ($location == "russia") {
$flag = "uploads/flags/ru.gif";
}
if ($location == "southafrica") {
$flag = "uploads/flags/sa.gif";
}
if ($location == "spain") {
$flag = "uploads/flags/sn.gif";
}
if ($location == "sweden") {
$flag = "uploads/flags/se.gif";
}
if ($location == "switzerland") {
$flag = "uploads/flags/ch.gif";
}
if ($location == "turkey") {
$flag = "uploads/flags/tr.gif";
}
if ($location == "uk") {
$flag = "uploads/flags/england.gif";
}
if ($location == "wales") {
$flag = "uploads/flags/wales.gif";
}
?>
<img src="<?php echo $flag; ?>" alt="<?php echo $location; ?>" /> <?php echo ucfirst($username); ?> "<span style="color:#03A7FF; text-decoration:underline;"><?php echo $game; ?></span>"
<?php
	}
}
}
?>
                <div id="player">
Click a player to get information
                </div>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.