A revolving earth (earthani.gif--64x64) Beaverland Net
JavaScript Made Easy!
 
Japanese Version (japanv.gif--100x36)

Beaverland JavaScript Made Easy logo (javascrx.gif--140x233)

Beaverland Unlisted Slang logo (slangs2.gif--140x260)

Beaverland Historica logo (histbanr.jpg--140x360)

Beaverland Mythology logo (mythbanr.jpg--140x255)

Beaverland Stries logo (stories.jpg--140x276)

Beaverland Webs & Internet Secrets logo (web100.jpg--140x250)

Beaverland Cleopatra Gallery logo (galleryt.gif--177x275)

Beaverland Ciold War Years logo (coldwrbn.jpg--140x320)


onstore.gif (140x93)

beavbook.gif (120x160)

beavcomp.gif (120x160)

beavmovi.gif (120x160)

beavgift.gif (120x160)

beavtrav.gif (120x160)

music.gif (50x50) Beaverland Music
 
How to use a table with Javascript
September 15, 2003

 

Upper left (ba0103a1.gif--220x390) Upper middle (ba0103a2.gif--70x390) Upper right (ba0103a3.gif--148x390)
Middle (ba0103b.gif--438x290)
Lower left (ba0103c1.gif--220x140) Lower middel (ba0103c2.gif--70x140) Lower right (ba0103c3.gif--148x140)

  • Please click her bra to let her drop it.

  • To get it back to her hand, click the bra on the ground.

  • If your screen is a little bit too small for the above picture, press F11 key to widen your screen to the full.

 

 

How does it work?

The above picture actually consists of seven parts as shown below:

 

Upper left (ba0103a1.gif--220x390) Upper middle (ba0103a2.gif--70x390) Upper right (ba0103a3.gif--148x390)
Middle (ba0103b.gif--438x290)
Lower left (ba0103c1.gif--220x140) Lower middel (ba0104c2.gif--70x140) Lower right (ba0104c3.gif--148x140)

Each part is arranged in a table so that you can manipulate specific parts. The code is as follows:

<table width="438" height="820" border="0"
    cellpadding="0" cellspacing="0">
<tr><td>
<img name="face" src="../eroshist/images/ba0103a1.gif"
    alt="Upper left (ba0103a1.gif--220x390)"
    width="220" height="390">
</td>
<td>
<img src="../eroshist/images/ba0103a2.gif"
    alt="Upper middle (ba0103a2.gif--70x390)"
    width="70" height="390">
</td>
<td>
<a href="javascript:document.face.src=
        '../eroshist/images/ba0104a1.gif';
    document.braup.src=
        '../eroshist/images/ba0104a3.gif';
    document.bradown2.src=
        '../eroshist/images/ba0104c2.gif';
    document.bradown3.src=
        '../eroshist/images/ba0104c3.gif';
    void(0);">
<img name="braup" border="0"
    src="../eroshist/images/ba0103a3.gif"
    alt="Upper right (ba0103a3.gif--148x390)"
    width="148" height="390"></a>
</td></tr>

<tr><td colspan="3">
<img src="../eroshist/images/ba0103b.gif"
    alt="Middle (ba0103b.gif--438x290)"
    width="438" height="290">
</td></tr>

<tr><td>
<img src="../eroshist/images/ba0103c1.gif"
    alt="Lower left (ba0103c1.gif--220x140)"
    width="220" height="140">
</td>
<td>
<img name="bradown2"
    src="../eroshist/images/ba0103c2.gif"
    alt="Lower middel (ba0103c2.gif--70x140)"
    width="70" height="140">
</td>
<td>
<a href="javascript:document.face.src=
        '../eroshist/images/ba0103a1.gif';
    document.braup.src=
        '../eroshist/images/ba0103a3.gif';
    document.bradown2.src=
        '../eroshist/images/ba0103c2.gif';
    document.bradown3.src=
        '../eroshist/images/ba0103c3.gif';
    void(0);">
<img name="bradown3" border="0"
    src="../eroshist/images/ba0103c3.gif"
    alt="Lower right (ba0103c3.gif--148x140)"
    width="148" height="140"></a>
</td></tr>
</table>

Each colored background corresponds to the part of the same color in the above picture. The parts on which you want to manipulate are named as shown below:

A divided picture of a bra-dropping girl (bra04.jpg--227x419)

As shown in the above coding sheet, they are coded in the following manner:

document.face.src
document.braup.src
document.bradown2.src
document.bradown3.src

The idea is that, when you click the specific part of the picture, the Javascript will replace the related parts with the appropriate segments as shown below:

Upper left (ba0103a1.gif--220x390) Upper middle (ba0103a2.gif--70x390) Upper right (ba0103a3.gif--148x390)

<table width="438" height="390" border="0"
    cellpadding="0" cellspacing="0">
<tr><td>
<img name="face2" src="../eroshist/images/ba0103a1.gif"
    alt="Upper left (ba0103a1.gif--220x390)"
    width="220" height="390">
</td>
<td>
<img src="../eroshist/images/ba0103a2.gif"
    alt="Upper middle (ba0103a2.gif--70x390)"
    width="70" height="390">
</td>
<td>
<a href="javascript:document.face2.src=
        '../eroshist/images/ba0104a1.gif';
    document.braup2.src=
        '../eroshist/images/ba0104a3.gif';
    void(0);">
<img name="braup2" border="0"
    src="../eroshist/images/ba0103a3.gif"
    alt="Upper right (ba0103a3.gif--148x390)"
    width="148" height="390"></a>
</td></tr>
</table>

<input type="button" value="Restore!"
  onClick="document.face2.src=
        '../eroshist/images/ba0103a1.gif';
    document.braup2.src=
        '../eroshist/images/ba0103a3.gif'">

For the above demo, I use different names (face2 and braup2) because JavaScript does not allow me to use the identical name on the same page.

A girl looking down (ba0104a1.gif--220x390) When you click the bra above, the href= attribute executes three JavaScript statements. The first statement will replace the part called face2 with the picture (ba0104a1.gif) at right.

 

A girl looking down (ba0104a1.gif--148x390) The second statement will replace the part called braup2 with the picture (ba0104a3.gif) at right.

 

The third statement actually does nothing, but this statement is required to prevent the following weird event from taking place.

Upper left (ba0103a1.gif--220x390) Upper middle (ba0103a2.gif--70x390) Upper right (ba0103a3.gif--148x390)

When you click the bra, your browser will display the name of the second picture for replacement on a blank page.

To get back here, please click the back button on your browser.

 

What the heck happned?

Well, nobody is perfect, and nothing is perfect.
Apparently, JavaScript loaded the name—that is, a string value—instead of its target: the picture itself.

The void() evaluates its parameter and executes it if it is a statement. Alternatively, to prevent the above strange event, you can write it in the following manner:

<a href="javascript:void(document.face3.src=
        '../eroshist/images/ba0104a1.gif');
    void(document.braup3.src=
        '../eroshist/images/ba0104a3.gif')">

When you click the button, the event handler (onClick) will restore the picture. This time, you don’t need void() in the code. Strange, isn’t it?

 

Chipmunk pointing to the left (chipleft.gif--178x156) Related Links





Rate article:
Excellent Good Neutral Poor Worst

Your Name:
Your Email Address:
Comments:


  Comments
 
It’s a nice demo, but do you know it takes quite a while for the replacement pictures to get loaded?
    - Tommy Hulks

Yes, I know. I made another demo to speed up the process. Please click the following link:

How to speed up pictorial presentation.

    - Akira

 
 
Copyright Akira Kato
About this author:
  • Educated both in Canada and Japan
  • Traveled extensively in Europe, Far East, and North America
  • Worked as management consultant, computer systems analyst, college instructor and freelance writer.
Akira Kato

Everything on
007 James Bond
from Amazon.com

Beaverland Forum
Featuring thought-provoking
columns and stories
inserted by FC2 system