Jump to content
MakeWebGames

onClick (itmname) images show (itmpic)


S.Cosmin

Recommended Posts

The basic idea you are looking for is this, for simplicity of reading this reply, the style is inline.

Demo: http://www.pure2012.com/testcolor.php

 

[noparse]
<script type="text/javascript">
function hint(id){
var z=document.getElementById(id);
if(z.style.display == 'none'){ 
	z.style.display='inline'; 
}else{
	z.style.display='none'; 
}
}
</script>
<a style="cursor:pointer;" onmouseover="hint('hello');" onmouseout="hint('hello');">Hover me?</a><br>
<div id="hello" style="display:none;">hello world</div>
[/noparse]
Edited by runthis
Link to comment
Share on other sites

Thank you bouth, i have use mixmaster mod i done all but why cant see the image?

this is the code in js

tooltips[3]=["{$i['itmpic']}", "Bridge to somewhere.", {background:"white", font:"bold 12px Arial"}]

Will bi this the problem {$i['itmpic']} ? But how to fix...

Did you download both the files and upload them to your server ?

Link to comment
Share on other sites

I can't get this to work either, I'm calling it like this in inventory:

print "<tr><td><a href='inventory.php#' rel='imgtip[0]'>[{$i['itmname']}]</a>";

And here's what I got in the js file:

tooltips[0]=["images/$i['image']", "$i['itmname']", {background:"#FFFFFF", color:"black", border:"5px ridge darkblue"}]

Am I doing something wrong there? I tried Lithium's method too and that didn't work

Link to comment
Share on other sites

JavaScript cannot directly execute serverside code, since it runs on the client, which you seem to have a grasp on already. What AJAX (just a fancy acronym for a variety of techniques) does is simple. The script indirectly executes serverside code by requesting a new page, preferably asynchronously and in the background so the client won't have to wait for a page reload etc.

Since the server must know what data it should send back, you need to send some kind of data/instructions. You can either append it to the url as a querystring (a GET request) or make a POST request, like forms do. The instruction telling the server what to do could just as well had been the name of the requested document or placed into a custom header (not guaranteed to reach the server), but grabbing GET or POST data serverside is a bit more convenient.

The reply from the server could be anything from partial (X)HTML, which could be inserted somewhere on the page, or some other form of data which the clientside script knows how to parse. XML is often used for this, which is why it got called Asynchronous JavaScript And XML.

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...