Eminem Posted March 15, 2007 Share Posted March 15, 2007 Is there a code that enables one to click something to show it, then click it again to hide it? Let's say there's an image, when someone clicks it text appears under it, when someone clicks it again the text disappears. Quote Link to comment Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 Javascript is what you want with the document DOM and CSS styles. This is posted in the wrong forum. Should be Javascript. Quote Link to comment Share on other sites More sharing options...
Eminem Posted March 15, 2007 Author Share Posted March 15, 2007 Javascript is what you want with the document DOM and CSS styles. This is posted in the wrong forum. Should be Javascript. Is there a way to get Javascript into a php file? Should I do this: <php? phpcodehere ?> javascript <php? Quote Link to comment Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 That works or assigning it to a variable and printing that or just print, there are many ways, which way is best depends on your preference. Quote Link to comment Share on other sites More sharing options...
EagerWolf Posted March 15, 2007 Share Posted March 15, 2007 Your problem can be solved with DIV layers... Instead of href use onClick or onMouseOver (up to you ... what you like most) and onClick call JS ... You should define div layer with height '0' and positioning to absolute and overflow should be disabled. In JS you should resize this layer to whatever you want.. With a little knowledge about JS you should understand code below: <script type="text/javascript"> var o; function big(n, obj) { setTimeout('bigcall("'+n+'")', 0); } function bigcall(n) { var obj = document.getElementById('im'); o.innerHTML = '<img src="'+n+'" />'; o.style.left = (obj.offsetWidth - 10) + "px"; o.style.top = (obj.offsetHeight - 10) + "px"; o.style.visibility = 'visible'; } function big_hide() { setTimeout('big_hide1()', 1000); } function big_hide1(num) { o.style.visibility = 'hidden'; } function init() { o = document.getElementById('ro'); } </script> This is made for pictures: "bigcall('path_to_picture')" Use this in onClick to call function bigcall... In body must be defined: onload="init();" This will make o (look in script).. And div layer must be defined with ID (in this case 'ro') <div id="ro" style="visibility:hidden; position:absolute;"></div> With this script you should solve your problem with a few modifications. In function bigCall there is timeout function ... This is used if you want a little delay when mouse goes over. If you have any problems feel free to ask... This code is just a quick example.. I hope it will help you... Best regards, EW Quote Link to comment Share on other sites More sharing options...
EagerWolf Posted March 15, 2007 Share Posted March 15, 2007 JS should be add before <?php ... in fact it should be in head of documet... If you printed whole HTML (I do not prefer this) you should print it as well... Quote Link to comment Share on other sites More sharing options...
Eminem Posted March 15, 2007 Author Share Posted March 15, 2007 Something that probably complicates the situation is the fact that I want to be able to click a user's avatar in an SMF Forum to show the personal text, custom profile field, country flag, personal text, and other stuff that goes under the user's avatar in the post. Quote Link to comment Share on other sites More sharing options...
EagerWolf Posted March 15, 2007 Share Posted March 15, 2007 Although I don't imagine what exactly you want to do I think it can be easily done ... Text should be hidden and in div (same div as picture) than on click text should be set to proper size and shown and layer should be set to auto width and height ... You can describe a little bit more (is there any example, picture) and I will help tomorrow (will be away now - sleep time ) if you are not successful today. Best regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.