Closed Thread Icon

Topic awaiting preservation: beginner Jscript IF statement help (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=21841" title="Pages that link to Topic awaiting preservation: beginner Jscript IF statement help (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: beginner Jscript IF statement help <span class="small">(Page 1 of 1)</span>\

 
jdizzle
Neurotic (0) Inmate
Newly admitted

From:
Insane since: May 2004

posted posted 05-18-2004 02:23

I want to have a box appear if it is not there and disappear if it is, triggered by a click.

function sT(){
if (document.getElementById('tB').style.visibility == hidden){
document.getElementById('tB').style.visibility='hidden'
}
else {
document.getElementById('tB').style.visibility='visible';}


this is what I have now.... I have tried EVERYTHING....
My original:

function sT(){
document.getElementById('tB').style.visibility='visible';}

works to make box appear, but that is it.

Thank You for your help!

Yossi Admon
Bipolar (III) Inmate

From: Israel
Insane since: Nov 2001

posted posted 05-18-2004 07:40

You are trying to ask "if (document.getElementById('tB').style.visibility == hidden){" where the hidden should be a string and not undefined variable.
you can try the following code (if you dont like the ...style.display... you can modify it to ...style.visibility...):

code:
function sT(){
InvertState(document.getElementById('tB'));
}

function InvertState(oElem){
if(oElem.style.display == 'block'){
oElem.style.display = 'none'
} else {
oElem.style.display = 'block'
}
}

jdizzle
Obsessive-Compulsive (I) Inmate

From:
Insane since: May 2004

posted posted 05-18-2004 22:48

I'm sorry I tried that... I eventually get to a point where I don't know what ic could be and I just start changin syntax type things. Like paranethese, commas, etc.

jdizzle
Obsessive-Compulsive (I) Inmate

From:
Insane since: May 2004

posted posted 05-18-2004 22:48

Are the semicolons the problem?

norm
Paranoid (IV) Inmate

From: [s]underwater[/s] under-snow in Juneau
Insane since: Sep 2002

posted posted 05-18-2004 23:15

javascript:

code:
function toggleVisibility(item){

if (document.getElementById(item).style.visibility=='hidden'){
document.getElementById(item).style.visibility='visible';
}
else{
document.getElementById(item).style.visibility='hidden';
}
}



HTML:

<div id="toggle" onclick="toggleVisibility('target')">Click to toggle</div>
<br /><br />
<div id="target">Can you see this?</div>

/* Sure, go ahead and code in your fancy IDE. Just remember: it's all fun and games until someone puts an $i out */

jdizzle
Obsessive-Compulsive (I) Inmate

From:
Insane since: May 2004

posted posted 05-20-2004 02:35

Thank you very much norm!!

« BackwardsOnwards »

Show Forum Drop Down Menu