ccrevcypsys Posted August 28, 2007 Share Posted August 28, 2007 Hey guys i just have a question. I need a code to hide the whole data base pull so that it says exampl... then when they hover over that it says the full name. so heres another example Artist | Song | Album Slipknot | The Heretic A... | Iowa Then on mouse hover it says The Heretic Anthem? anyone have anything like that or know where i can get it? Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/ Share on other sites More sharing options...
Psycho Posted August 28, 2007 Share Posted August 28, 2007 <?php $trackname = "The Heretic Anthem"; $shortTrack = (strlen($trackname)>16) ?substr($trackname,0,13).'...':$trackname; echo "<a href=\"#\" title=\"$trackname\">$shortTrack</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-336621 Share on other sites More sharing options...
ccrevcypsys Posted August 30, 2007 Author Share Posted August 30, 2007 Ok well i took that code and implimented my own code to make it work for my site. But the thing is it isnt working. It posts the first and last name but doesnt put the ... and i know the class is different then most the $view_cat->assign("TXT_ARTIST", $shortTrack); is the echo <?php $trackname = $productResults[$i]['firstName']." ". $productResults[$i]['lastName']; $shortTrack = (strlen($trackname>10) ?substr($trackname,0,."...":$trackname); $view_cat->assign("TXT_ARTIST", $shortTrack); ?> [/code Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337858 Share on other sites More sharing options...
GingerRobot Posted August 30, 2007 Share Posted August 30, 2007 Try using: $shortTrack = strlen($trackname) > 10 ? substr($trackname,0,."...": $trackname; However, you're going to need to be echoing some javascript along with this too if you want to allow people to hover over the text to show the whole lot. Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337867 Share on other sites More sharing options...
ccrevcypsys Posted August 30, 2007 Author Share Posted August 30, 2007 Do u know where i can get this java script code? Try using: $shortTrack = strlen($trackname) > 10 ? substr($trackname,0,."...": $trackname; However, you're going to need to be echoing some javascript along with this too if you want to allow people to hover over the text to show the whole lot. Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337883 Share on other sites More sharing options...
GingerRobot Posted August 30, 2007 Share Posted August 30, 2007 Here's an example of how it might work: <script type="text/javascript"> function showall(id,text){ document.getElementById(id).innerHTML=text } function showshort(id,text){ document.getElementById(id).innerHTML=text } </script> <span id="test" onmouseover="showall(this.id,'the full text')" onmouseout="showshort(this.id,'the full...')">the full...</span> However, that would simply make everything wider. I guess what you're really after is some sort of tooptip to appear above the text. I know there are lots of these that you can find on the web. I suggest you google. Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337890 Share on other sites More sharing options...
ccrevcypsys Posted August 30, 2007 Author Share Posted August 30, 2007 I know i was going to google it i just wanted to know if you knew one thank you Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337904 Share on other sites More sharing options...
Psycho Posted August 30, 2007 Share Posted August 30, 2007 If all you want is some simple popup text (i.e. no formatting) - then you do not need javascript. Just simply use the title attribute. If it will be a link, use the title attribute inside the link tag. If it is just text on the screen that you want the popup on, put the text in a span with the title attribute. Works in IE and FF. <span title="A bird in the hand is worth two in the bush">A bird in the hand is...</span> Quote Link to comment https://forums.phpfreaks.com/topic/67116-solved-quick-question-code-request/#findComment-337992 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.