[Javascript] show hide a text when checking a checkbox ?

Peter Brunone peter at brunone.com
Tue Jun 5 13:05:49 CDT 2001


    First you'll need an onClick event handler in the checkbox, like this:

<INPUT TYPE="CHECKBOX" NAME="switchBox"
onClick="showHideText(this,'myText')">

    Next you'll need a DIV that contains the text you want to show/hide,
like this:

<DIV ID="myText">Put text here</DIV>

Then you'll need the JavaScript function to hide the text, like this:

function showHideText(boxName,divName) {
    if(boxName.checked = true) {
        showObject(divName);
        }
    else {
        hideObject(divName);
        }
    }

    Finally you'll need your showObject and hideObject functions.  I like to
use the ones at www.dansteinman.com/dynduo ; they're easy to implement and
they work well for Netscape and Explorer.

Cheers,

Peter Brunone

----- Original Message -----
From: "yahress nataf" <yna54 at hotmail.com>
To: <javascript at LaTech.edu>
Sent: Tuesday, June 05, 2001 5:41 PM
Subject: [Javascript] show hide a text when checking a checkbox ?


> How to do it ?
> Thanks
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
>





More information about the Javascript mailing list