Tuesday, October 4, 2016

Dynamically shorten and Expand the Text

///////////////////////////////////////////////////////////////////////////////////////////////////
//// index.php
///////////////////////////////////////////////////////////////////////////////////////////////////
<script>
function abc(){
var lngdscp=document.getElementById("discplg").innerHTML;
var stdscp=document.getElementById("discpst").innerHTML;
var anchor = document.getElementsByTagName("a");
var x = anchor[0].innerHTML;
alert(x);
  if(x=="More&gt;&gt;"){
    alert("greater");
  var x = anchor[0].innerHTML="Less&lt;&lt;";
  document.getElementById("discp").innerHTML=lngdscp;

  }
  else{
     var x = anchor[0].innerHTML="More&gt;&gt;";
 document.getElementById("discp").innerHTML=stdscp;
  }



  alert(lngdscp);
}
</script>

<?php
$description='How High Would You Draft Marcus Mariota ? First Take Today - Thursday - April 30 2015 | Skip Bayless & Stephen A. Smith 4-30-15 Live on Floyd Mayweather vs Manny Pacquiao - Saturday, May 2 at the MGM Grand Garden Arena in Las Vegas, Nev. Watch First Take on Facebook : http://goo.gl/uQM5uD ESPN First Take Full | First Take | Skip Bayless & Stephen A. Smith "ESPN First Take" "First Take" "Skip Bayless" "Stephen A. Smith" First Take - Skip Bayless and Stephen A. Smith discuss First Take News, Videos, Photos, and PodCasts - ESPN First Take - ESPN Topics - ESPN 2 - ESPN.com First Take is an American morning sports talk program on ESPN2 and ESPN2HD. Two back-to-back two-hour episodes air each weekday from Monday through Friday, with the live episode airing from 10 a.m. ET until noon, followed by a repeat. Facebook : https://www.facebook.com/FirstTake Follow us on twitter - http://twitter.com/espn_firsttake "ESPN First Take" "First Take" "Skip Bayless" "Stephen A. Smith" "espn 1st take" "1st take"';

$myarray=array();
$myarray=explode(" ",$description);
echo '<pre>';
$st="";
for($i=0;$i<10;$i++){
$st.=$myarray[$i];
$st.=" ";
}
echo "<table>";
echo "<tr><td width='500'><strong><font color=red>Description:</font></strong><div id='discp'>".$st."</div><a href='javascript:void(0)' onclick='abc()'>More>></a></div></td></tr>";
echo "</table>";


?>

<div id="discplg" style="display:none">
 <?php echo $description;?>
</div>
<div id="discpst" style="display:none">
 <?php echo $st;?>
</div>

///////////////////////////////////////////////////////////////////////////////////////////////////
//// End index.php
///////////////////////////////////////////////////////////////////////////////////////////////////

No comments:

Post a Comment