I am using Javascript to hide / show a blog-post stored in a mysql table. The script for doing this is:
<script type="text/javascript">
function unhide(divID) {
var item = document.getElementById(divID);
if (item) {
item.className = (item.className == 'hidden') ? 'unhidden' : 'hidden';
}
}
</script>
This links to some css styling:
.hidden {
display: none;}
.unhidden {
display: inline;}
I am calling the script via a href styles as a button:
<a class=button href="javascript:unhide('first_post');">More</a>
As for the content I originally tried the following to initially show a small section of text, then the rest after the link is clicked:
<?php $var = mysql_result($result,0,"post_text"); ?>
<?php echo substr($var, 0, 400); ?>
<div id="first_post" class = "hidden">
<?php echo substr($var, 400, 5000)?>
</div>
However where the two sets of sub-strings join there is a space. For example if the first sub-string ends in "the tree's hav" and the second sub-string starts "e eyes you know" the concatenation results in "the trees hav e eyes you know"
Can anyone help me with this problem?