Current location: Hot Scripts Forums » General Web Coding » CSS » tab separated news content


tab separated news content

Reply
  #1 (permalink)  
Old 09-26-08, 03:46 PM
shout it shout it is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
tab separated news content

I have got some code for a news display table. the top row contains the link eg, us news uk news business news sport weather etc.
the row below will such the content of the click link.
I am having a problem when the page loads it show the hyperlinks but no content, what i am trying to do is to have one of the links content displayed when the page is loaded eg when the page loads the us news content will be displayed by default. the code i have used is given below::

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Hidden DIVs</title>
<style type="text/css">
.news {
display: none;
}
</style>
<script type="text/javascript">
function hideSections() {
document.getElementById('news-us').style.display='none';
document.getElementById('news-uk').style.display='none';
document.getElementById('news-africa').style.display='none';
}
function showNews(section) {
hideSections();
newsItem = document.getElementById('news-'+section);
if (newsItem) {
newsItem.style.display='block';
}
}
</script>
</head>
<body>
<table style="text-align: left; width: 100%;" border="2" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="text-align: center;"><a onclick="showNews('us');" href="#">US News</a></td>
<td style="text-align: center;"><a onclick="showNews('uk');" href="#">UK News</a></td>
<td style="text-align: center;"><a onclick="showNews('africa');" href="#">Africa News</a></td>
</tr>
<tr>
<td colspan="3">
<div class="news" id="news-us">
<p>This is the news from the US:</p>
<p>The economy is in SERIOUS trouble! &nbsp;Yikes!!!!!</p>
</div>
<div class="news" id="news-uk">
<p>This is the news from the UK:</p>
<p>Jaguar Motorcars unveils a stunning new Jag today.</p>
</div>
<div class="news" id="news-africa">
<p>This is the news from Africa:</p>
<p>The Pharoahs have returned to build a new, state of the
art pyramid.</p>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>Peace...

thanks for looking any help to have one of the links content as displayed content on page load up will be gratefull accepted
Reply With Quote
  #2 (permalink)  
Old 10-12-08, 03:29 PM
s1yfa's Avatar
s1yfa s1yfa is offline
Newbie Coder
 
Join Date: Dec 2005
Location: Sheerness, Kent UK
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
if you want a particular div to show itself when you load the page, you need to say so in the code.

simple replace your opening <body> with
HTML Code:
<body onLoad="showNews('us');">
__________________
Users /nm./: collective term for those who use computers.
Novice Users: people who are afraid that simply pressing a key might break their computer.
Intermediate Users: people who don't know how to fix their computer after they've just pressed a key that broke it.
Expert Users: people who break other people's computers.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Have one tab separated file with one product/line and want to update an sql Oskare100 PHP 5 03-13-08 01:09 PM
Problem with layout bertrand HTML/XHTML/XML 4 11-08-07 07:30 AM
hideORshow tables, divs, or rows--need assistance deltatango5 JavaScript 2 09-20-06 08:48 AM
Error On Registeration timmy408 ASP 2 09-05-04 02:53 PM


All times are GMT -5. The time now is 02:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.