PDA

View Full Version : Need Some Help



talent
02-10-2009, 08:08 AM
I am trying to use a ajax and javascript code that i have for a site. 0n the Divisions area you are suppose to be able to click on the different divisions and the images below it will change to the proper division. I cant seem to get the javascript to work. What am I missing? This is what I have in my header

<script src="js/bbcode.js" language="jscript" type="text/javascript"></script>
<script src="ajax.php" type="text/javascript"></script>
<script type="text/javascript">

function getsquad(squadid, img){
ajax_request(squadid);
if(img == "cod4") {
document.getElementById(img).src = "images/icons/rostericon/cod4selected.jpg";
document.getElementById("css").src = "images/icons/rostericon/css.jpg";
document.getElementById("cod5").src = "images/icons/rostericon/cod5.jpg";
}
else if(img == "css") {
document.getElementById(img).src = "images/icons/rostericon/cssselected.jpg";
document.getElementById("cod4").src = "images/icons/rostericon/cod4.jpg";
document.getElementById("cod5").src = "images/icons/rostericon/cod5.jpg";
}
else if(img == "cod5") {
document.getElementById(img).src = "images/icons/rostericon/cod5selected.jpg";
document.getElementById("cod4").src = "images/icons/rostericon/cod4.jpg";
document.getElementById("css").src = "images/icons/rostericon/css.jpg";
}
}

function shownick(userid,nickname,firstname,lastname){
document.getElementById("overnick").innerHTML = '&nbsp;<a href="index.php?site=profile&amp;id='+userid+'" class="overnick">'+firstname+' \''+nickname+'\' '+lastname+'</a>';
}

</script>
<script type="text/javascript" src="tabcontent.js">
/***********************************************
* Tab Content script v2.0- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

This is what php it points too

<?php
if(!ereg('index.php',$_SERVER['PHP_SELF'])){
include("_mysql.php");
include("_settings.php");
include("_functions.php");
}
if(isset($_GET['s'])) $squad = $_GET['s'];
else $squad = 1;
$squad--;
$get = safe_query("SELECT * FROM ".PREFIX."squads LIMIT $squad,7");
$data = mysql_fetch_assoc($get);
$get_member = safe_query("SELECT * FROM ".PREFIX."squads_members WHERE squadID = '".$data['squadID']."' LIMIT 0,4");
while($ds = mysql_fetch_array($get_member)){
$pics .="<td align='center'><img src='images/avatars/".getavatar($ds['userID'])."' onmouseover='javascript:shownick(\"".$ds['userID']."\",\"".getnickname($ds['userID'])."\",\"".getfirstname($ds['userID'])."\",\"".getlastname($ds['userID'])."\");' alt='".getnickname($ds['userID'])."' height='55'/></td>";
"</b></td>";
}
echo " <table cellpadding = '0' cellspacing = '5' style='margin:0px; padding:0px;'>
<tr>".$nicks."</tr>
<tr>".$pics."</tr>
</table>";
?>

Also one last thing. On the roster images part of it how do I add more lines to it. Right now its
image image image image


I would like it
image image image image
image image image image
image image image image

I am really a novise at code. just would like a little help. I have tried everything i could think of through trial and error. No luck.

talent
02-11-2009, 02:30 AM
no one?

smansakra
02-11-2009, 09:46 AM
to get fast answer, you'd better make your quenstions easy and simple

talent
02-11-2009, 09:51 AM
Dont know if i am smart enough to do that. HAHA! I will try!

at the site www.the-leg.net/xcg when you click the different divisions on the right the javascript is suppose to change the images it doesn not. Am I missing a script?

Also I would like to add a row to the images, which I believe is a ajax code. So the images will be 4 rows of 4, not one row of 4

codeexploiter
02-11-2009, 11:21 AM
When you click the division the image is changing like the way you've mentioned. Regarding the ajax part the calls are going and comes with a response, but for further checking plz provide some code related to that.

talent
02-11-2009, 06:05 PM
The images that say cod4, css and cod5 change yes. Although when you click on those I am expecting the pictures below that to change. As they do not. I am not sure what code you are asking for. The one I posted was one of them and this is the ajaxs code.

<?php
header("Content-Type: text/javascript");
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$get = safe_query("SELECT * FROM ".PREFIX."squads");
?>
squads = new Array();
<?php
$i=1;
while($ds = mysql_fetch_array($get)){
echo "squads[".$i."] = '".$ds['name']."';\n";
$i++;
}
?>
cur = 1;
var max = <?=mysql_num_rows($get);?>;
var http_request = false;
function ajax_request(url) {
if(url<=0) url = max;
if(url>max) url = 1;
cur = url;
url = 'ajax_squads.php?s='+url;
//alert(cur);
http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// zu dieser Zeile siehe weiter unten
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
//$(div).innerHTML = 'Ende :( Kann keine XMLHTTP-Instanz erzeugen';
return false;
}
http_request.onreadystatechange = function (){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//$(div).innerHTML = http_request.responseText;
// $('squad_name').innerHTML = squads[cur];
//alert(http_request.responseText);
} else {
//$(div).innerHTML = 'Bei dem Request ist ein Problem aufgetreten.';
}
}
};
http_request.open('GET', url, true);
http_request.send(null);

}

talent
02-11-2009, 09:02 PM
since i suck at explaining this here is a image to show what i am talking about

http://the-leg.net/xcg/images/dynamic.jpg

Also would like it like this
http://the-leg.net/xcg/images/dynamic2.jpg

talent
02-13-2009, 07:07 AM
this seems like the file that does most the work. Is something not closed off in it?

<?php
header("Content-Type: text/javascript");
include("_mysql.php");
include("_settings.php");
include("_functions.php");
$get = safe_query("SELECT * FROM ".PREFIX."squads");
?>
squads = new Array();
<?php
$i=1;
while($ds = mysql_fetch_array($get)){
echo "squads[".$i."] = '".$ds['name']."';\n";
$i++;
}
?>
cur = 1;
var max = <?=mysql_num_rows($get);?>;
var http_request = false;
function ajax_request(url) {
if(url<=0) url = max;
if(url>max) url = 1;
cur = url;
url = 'ajax_squads.php?s='+url;
//alert(cur);
http_request = false;

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
// zu dieser Zeile siehe weiter unten
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
//$(div).innerHTML = 'Ende :( Kann keine XMLHTTP-Instanz erzeugen';
return false;
}
http_request.onreadystatechange = function (){
if (http_request.readyState == 4) {
if (http_request.status == 200) {
//$(div).innerHTML = http_request.responseText;
// $('squad_name').innerHTML = squads[cur];
//alert(http_request.responseText);
} else {
//$(div).innerHTML = 'Bei dem Request ist ein Problem aufgetreten.';
}
}
};
http_request.open('GET', url, true);
http_request.send(null);

}