philrivoire
02-28-2012, 06:03 PM
Hello,
I am currently working on my school's website. The site is laid out with a DIV on the left set up as a menu (called "leftmenu") and a DIV to the right to display the content (called "maincontent"). Clicking a link in leftmenu calls a script which changes the content of "maincontent".
The script currently works as it should except for one small error. The appropriate heading, text and image load for each link, but the formatting between the image and the paragraph is lost. When the page originally loads, the image is set to "float:left" and the paragraph wraps around it to the right. However, when the script runs and changes the contents, the paragraph no longer wraps around the image, but is written below it.
Javascript function:
var nov12="News for November 12";
var nov11="News for November 11";
var nov10="News for November 10";
function writeNews(title,image,txt)
{
document.getElementById("newsTitle").innerHTML=title;
document.getElementById("newsImage").src=image;
document.getElementById("newsText").innerHTML=txt;
}
HTML for the links calling the function and maincontent:
<div class="leftmenu">
<h3>News</h3>
<ul class="leftmenu">
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 12','img1.jpg',nov12)">Nov 12</a></li>
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 11','img2.jpg',nov11)">Nov 11</a></li>
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 10','img3.jpg',nov10)">Nov 10</a></li>
</ul>
</div>
<div class="maincontent">
<h3 id="newsTitle">School News</h3>
<img id="newsImage" class="newsimagestyle" src="img1.jpg" />
<p id="newsText"><img id="newsImage" class="newsimagestyle" src="" />Select the date from the menu on the left for news posted on that day.</p>
</div>
I have also attached the "before.jpg" and "after.jpg" screen captures from the relevant section of the website so you can see what changes are happening to the formatting.
BEFORE:
10876
AFTER:
10877
Any help to keep the formatting in the same would be greatly appreciated. Thanks.
Phil
I am currently working on my school's website. The site is laid out with a DIV on the left set up as a menu (called "leftmenu") and a DIV to the right to display the content (called "maincontent"). Clicking a link in leftmenu calls a script which changes the content of "maincontent".
The script currently works as it should except for one small error. The appropriate heading, text and image load for each link, but the formatting between the image and the paragraph is lost. When the page originally loads, the image is set to "float:left" and the paragraph wraps around it to the right. However, when the script runs and changes the contents, the paragraph no longer wraps around the image, but is written below it.
Javascript function:
var nov12="News for November 12";
var nov11="News for November 11";
var nov10="News for November 10";
function writeNews(title,image,txt)
{
document.getElementById("newsTitle").innerHTML=title;
document.getElementById("newsImage").src=image;
document.getElementById("newsText").innerHTML=txt;
}
HTML for the links calling the function and maincontent:
<div class="leftmenu">
<h3>News</h3>
<ul class="leftmenu">
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 12','img1.jpg',nov12)">Nov 12</a></li>
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 11','img2.jpg',nov11)">Nov 11</a></li>
<li class="leftmenu"><a class="leftmenu" href="javascript:writeNews('November 10','img3.jpg',nov10)">Nov 10</a></li>
</ul>
</div>
<div class="maincontent">
<h3 id="newsTitle">School News</h3>
<img id="newsImage" class="newsimagestyle" src="img1.jpg" />
<p id="newsText"><img id="newsImage" class="newsimagestyle" src="" />Select the date from the menu on the left for news posted on that day.</p>
</div>
I have also attached the "before.jpg" and "after.jpg" screen captures from the relevant section of the website so you can see what changes are happening to the formatting.
BEFORE:
10876
AFTER:
10877
Any help to keep the formatting in the same would be greatly appreciated. Thanks.
Phil