4 Replies - 1296 Views - Last Post: 07 July 2010 - 07:26 AM

#1 dragger40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-January 09

Dynamic switchbox with Javascript, possible ?

Posted 06 July 2010 - 03:24 PM

Hi to all javascript coders,

I'd like to ask if my idea is possible or not. As I have almost no javascript experience, I don't really know the capability of this language.

My idea is to let the content in this "switchbox" automatically change after some seconds.
Posted Image

The code that belongs to this box is the following :
 <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td><img alt=" " src="images/index_51.jpg" width="107" height="14" /></td>
                            <td><a href="#" onclick="MM_showHideLayers('ne','','show','fo','','hide','cw','','hide','dl','','hide')"><img alt=" " src="images/index_52.jpg" width="25" height="14" border="0"/></a></td>
                            <td><img alt=" " src="images/index_53.jpg" width="10" height="14" /></td>
                            <td><a href="#" onclick="MM_showHideLayers('ne','','hide','fo','','show','cw','','hide','dl','','hide')"><img alt=" " src="images/index_54.jpg" width="31" height="14" border="0"/></a></td>
                            <td><img alt=" " src="images/index_55.jpg" width="9" height="14" /></td>
                            <td><a href="#" onclick="MM_showHideLayers('ne','','hide','fo','','hide','cw','','show','dl','','hide')"><img alt=" " src="images/index_56.jpg" width="39" height="14" border="0"/></a></td>
                            <td><img alt=" " src="images/index_57.jpg" width="8" height="14" /></td>
                            <td><a href="#" onclick="MM_showHideLayers('ne','','hide','fo','','hide','cw','','hide','dl','','show')"><img alt=" " src="images/index_58.jpg" width="28" height="14" border="0"/></a></td>
                          </tr>
                        </table></td>


and

<div id="ne" align="left" style="width:244px; overflow:hidden;"><? include("sc_headlines.php"); ?></div>
<div id="fo" align="left" style="width:244px;"><? include("latesttopics.php"); ?></div>
<div id="cw" align="left" style="width:244px;"><? include("sc_results.php"); ?></div>
<div id="dl" align="left" style="width:244px;"><? include("sc_files.php"); ?></div>


Now, my question is simple. Is it possible to do this ? (I assume it is, but I wouldn't have a clue on how to start on this)
If so, would someone be so kind to explain (with examples maybe, I dunno) how to do this ?
If you need more information to be able to help me, just ask.

Thank you in advance,

dragger40

Is This A Good Question/Topic? 0
  • +

Replies To: Dynamic switchbox with Javascript, possible ?

#2 husseycoding  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 52
  • View blog
  • Posts: 174
  • Joined: 23-June 10

Re: Dynamic switchbox with Javascript, possible ?

Posted 07 July 2010 - 12:58 AM

Hi dragger40,

I would strongly suggest you replace your table and data cell structure with a div build. By giving a div an id, you can then set any content you like to it using Javascript - see the getElementById() method which allows you to target, and also assign contents to a div.
Was This Post Helpful? 1
  • +
  • -

#3 dragger40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-January 09

Re: Dynamic switchbox with Javascript, possible ?

Posted 07 July 2010 - 05:26 AM

Thx for your fast reply hussey.

As stated before I have no experience with javascript.
I've looked up the getElementById() method and I think I understand how this works. But in the case of my switchbox, I'd like to be able to click through the different sections (News, Board, Results, Files) manually, but it should also change automatically.

I've no clue on how to implement what you advised me into this idea.
Was This Post Helpful? 0
  • +
  • -

#4 husseycoding  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 52
  • View blog
  • Posts: 174
  • Joined: 23-June 10

Re: Dynamic switchbox with Javascript, possible ?

Posted 07 July 2010 - 05:47 AM

Ok, well have a look at handlers such as onclick(), and for automated events that are timed look at setInterval() and setTimeout().

I realise you don't have any experience with Javascript, but you unfortunately are just going to have to get your head down and read up, a simple project such as this would be a great one to get you going on Javascript. Wouldn't you rather know that you have written the code yourself and understand what is going on rather than just using someone elses work and not have a clue what it is doing?

People are more than willing to lend a helping hand and give you pointers on these forums, but you won't find that anyone will jump at the chance of doing a project for you.
Was This Post Helpful? 0
  • +
  • -

#5 dragger40  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-January 09

Re: Dynamic switchbox with Javascript, possible ?

Posted 07 July 2010 - 07:26 AM

You're completely right about that mate.
But the problem is, I have not that much spare time available at this moment to learn javascript.

I'll try to come up with something this evening, but I'm not sure I will succeed at starting to write a script.

**EDIT**

Ok, I browsed through many javascript tutorials and also looked up the information you gave me. But I failed and couldn't start writing a script.

This post has been edited by dragger40: 07 July 2010 - 11:18 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1