needsomehelp
11-26-2012, 05:24 PM
Can anyone tell me why they think the following code is not showing the text beside the rest of the text.
What I was after is to have the visitor click the 'show more' link which opens up the rest of the text, but it is not showing it next to the text already there, it is breaking the text up with a new line. how can I get it so the text is all together, but at all times centered.
<!DOCTYPE HTML><html><head><title>Untitled Document</title><? echo('<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">'); ?>
<style>
.more { display: none; }
a.showLink, a.hideLink { text-decoration: none; color: #36f; padding-left: 8px; /*background: transparent url(down.gif) no-repeat left;*/ }
a.hideLink { /*background: transparent url(up.gif) no-repeat left;*/ }
a.showLink:hover, a.hideLink:hover { border-bottom: 1px dotted #36f; }
</style>
<script type="text/javascript">
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
</head><body>
<div style="width: 100px; font-size: 0.5em;">
<h1 style="text-align: center;"><?
$resultsTitle = "a very long title for the products as i need to know if this will wrap properly";
if (strlen($resultsTitle) < 30) { $top_desc = $resultsTitle; $more_desc = "";
} else {
//$top= strpos($resultsTitle." ", " ", 30);
$top_desc = substr($resultsTitle, 0, 30);
$more_desc = substr($resultsTitle, 30);
} ?>
<span style="float: left;"><? echo ($top_desc);
if ($more_desc != "") {
?><a href="#" id="textbox<? echo $results['itemid'];?>-show" class="showLink" onclick="showHide('textbox<? echo $results['itemid'];?>');return false;">.... See more</a><?
}
?></span><?
if ($more_desc != "") {
?><span style="float: left;" id="textbox<? echo $results['itemid']; ?>" class="more"><? echo ($more_desc);
?><br><a href="#" id="textbox<? echo $results['itemid']; ?>-hide" class="hideLink" onclick="showHide('textbox<? echo $results['itemid']; ?>');return false;">Hide this content</a><?
?></span><?
}
?></h1>
</div>
</body></html>
What I was after is to have the visitor click the 'show more' link which opens up the rest of the text, but it is not showing it next to the text already there, it is breaking the text up with a new line. how can I get it so the text is all together, but at all times centered.
<!DOCTYPE HTML><html><head><title>Untitled Document</title><? echo('<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">'); ?>
<style>
.more { display: none; }
a.showLink, a.hideLink { text-decoration: none; color: #36f; padding-left: 8px; /*background: transparent url(down.gif) no-repeat left;*/ }
a.hideLink { /*background: transparent url(up.gif) no-repeat left;*/ }
a.showLink:hover, a.hideLink:hover { border-bottom: 1px dotted #36f; }
</style>
<script type="text/javascript">
function showHide(shID) {
if (document.getElementById(shID)) {
if (document.getElementById(shID+'-show').style.display != 'none') {
document.getElementById(shID+'-show').style.display = 'none';
document.getElementById(shID).style.display = 'block';
}
else {
document.getElementById(shID+'-show').style.display = 'inline';
document.getElementById(shID).style.display = 'none';
}
}
}
</script>
</head><body>
<div style="width: 100px; font-size: 0.5em;">
<h1 style="text-align: center;"><?
$resultsTitle = "a very long title for the products as i need to know if this will wrap properly";
if (strlen($resultsTitle) < 30) { $top_desc = $resultsTitle; $more_desc = "";
} else {
//$top= strpos($resultsTitle." ", " ", 30);
$top_desc = substr($resultsTitle, 0, 30);
$more_desc = substr($resultsTitle, 30);
} ?>
<span style="float: left;"><? echo ($top_desc);
if ($more_desc != "") {
?><a href="#" id="textbox<? echo $results['itemid'];?>-show" class="showLink" onclick="showHide('textbox<? echo $results['itemid'];?>');return false;">.... See more</a><?
}
?></span><?
if ($more_desc != "") {
?><span style="float: left;" id="textbox<? echo $results['itemid']; ?>" class="more"><? echo ($more_desc);
?><br><a href="#" id="textbox<? echo $results['itemid']; ?>-hide" class="hideLink" onclick="showHide('textbox<? echo $results['itemid']; ?>');return false;">Hide this content</a><?
?></span><?
}
?></h1>
</div>
</body></html>