...

View Full Version : if all are hidden



chris_angell
07-25-2002, 03:49 PM
hello

I have some code to say if all dragable Divisions are hidden, pop up an alert box,, I am having troubles


well have a look..

this bit below is what I am working on

function check () {
if (document.all["folioweb1Div"+ "folioweb1Div"].style.visibility="hidden") {
alert('check1');
}

here is all the code.. is there any easier ways to say if all the dragable divisions are hidden pop the alert box up ???

function check() {
if (document.all["folioweb1Div" + "folioweb1Div"].style.visibility="hidden") {
alert('check1');
}
}
function portfolio() {
DynLayerInit()

drag.add(folioweb1,folioweb2,folioweb3,folioweb4,folioweb5,folioprint1,folioprint2,folioprint3,folio print4,folioprint5)

drag.addTargets(maintarget)
drag.onDragDrop = hitTarget

initMouseEvents()
}
function hitTarget() {
document.all[this.obj.id].style.visibility = "hidden"
window.open("
this.obj.id+".htm",'foliomain')
check ()
}

any ideas why it is not working.. I am not that hot at javascript

thanks :eek: cheers for all the help

MikoLone
07-25-2002, 07:28 PM
function check () {
if (document.all["folioweb1Div"+ "folioweb1Div"].style.visibility="hidden") {
alert('check1');
}



shouldn't your if statment look like this instead.



function check () {
if (document.all["folioweb1Div"+ "folioweb1Div"].style.visibility=="hidden") {
alert('check1');
}

chris_angell
07-25-2002, 08:44 PM
thanks to miko but :( but no jazz.. I have tried it many ways but

any help with this one.. or if else statments

var 1 = folioweb1Div.style.visibility
var 2 = folioweb2Div.style.visibility
var 3 = folioweb3Div.style.visibility

function check() {
if (1+2+3=="hidden") {
alert("please!");
return false;
}
}

will this work, :confused:

thanks :)

mordred
07-25-2002, 10:37 PM
No, that can't work at all, javascript identifier names mustn't start with numbers so the interpreter can differentiate between ordinary numbers and variables.

If you rename your variables say with a "vis" prepended, then the following should work for you:

function check() {

var vis1 = document.getElementById("folioweb1Div").style.visibility
var vis2 = document.getElementById("folioweb2Div").style.visibility
var vis3 = document.getElementById("folioweb3Div").style.visibility

if (vis1 =="hidden" && vis2 == "hidden" && vis3 == "hidden") {
alert("please!");
return false;
}
}

Note that in some cases, you can't read out the style values of elements, i.e. those defined by css classes immediately after they have been rendered by the browser.

chris_angell
07-26-2002, 11:45 AM
thanks mordred.. you are a winner

chris_angell
07-26-2002, 06:26 PM
thanks for the help above.. things at the moment are looking good.. but I have now another question..

in my code I have two dragable sections, print and web. but i have managed to make alert boxes come up when the five print or web divisions are hidden.. but I want when all divisions are hidden (print + web) the shake function to happen..

for example, 5 web divs hidden = alert box
for example, 5 print divs hidden = alert box
for example, 10 web plus print divs hidden = shake

here is my code what am I doing wrong ???????? it starts on hitTarget() then function checkweb()



function shake(n) {
if (parent.moveBy) {
for (i = 3; i > 0; i--) {
for (j = n; j > 0; j--) {
parent.moveBy(0,i);
parent.moveBy(i,0);
parent.moveBy(0,-i);
parent.moveBy(-i,0);
}
}
}
}
function checkshake() {

var left1 = document.getElementById("folioprint1Div").style.visibility
var left2 = document.getElementById("folioweb1Div").style.visibility

if (left1 =="visable" && left2 == "visable") {
shake(1);
return false;
}
}
}

function checkweb() {

var vis1 = document.getElementById("folioweb1Div").style.visibility
var vis2 = document.getElementById("folioweb2Div").style.visibility
var vis3 = document.getElementById("folioweb3Div").style.visibility
var vis4 = document.getElementById("folioweb4Div").style.visibility
var vis5 = document.getElementById("folioweb5Div").style.visibility
var vis6 = document.getElementById("folioprint1Div").style.visibility
var vis7 = document.getElementById("folioprint2Div").style.visibility
var vis8 = document.getElementById("folioprint3Div").style.visibility
var vis9 = document.getElementById("folioprint4Div").style.visibility
var vis10 = document.getElementById("folioprint5Div").style.visibility
var left1 = document.getElementById("folioprint1Div").style.left
var left2 = document.getElementById("folioweb1Div").style.left

if (left1 =="100" && left2 == "100") {
shake(1);
return false;
}
if (vis1 =="hidden" && vis2 == "hidden" && vis3 == "hidden" && vis4 == "hidden" && vis5 == "hidden") {
window.alert("that are a couple of sites I have done");
moveandshowweb()
return false;
}
if (vis6 =="hidden" && vis7 == "hidden" && vis8 == "hidden" && vis9 == "hidden" && vis10 == "hidden") {
window.alert("that was some of my old print work");
moveandshowprint()
return false;
}
}
function portfolio() {
DynLayerInit()

drag.add(folioweb1,folioweb2,folioweb3,folioweb4,folioweb5,folioprint1,folioprint2,folioprint3,folio print4,folioprint5)

drag.addTargets(maintarget)
drag.onDragDrop = hitTarget

initMouseEvents()
}
function hitTarget() {
document.all[this.obj.id].style.visibility = "hidden"
window.open("mainpages/"+this.obj.id+".htm",'foliomain')
document.dropname.src='images/web'+this.obj.id+'.gif'
checkweb()
}




:)

mordred
07-26-2002, 06:33 PM
Originally posted by chris_angell
if (left1 =="visable" && left2 == "visable") {
shake(1);
return false;


Sorry I haven't got the time to test it completely, but this seems like a typo for me: Shouldn't it rather be "visible" instead?

chris_angell
07-26-2002, 06:40 PM
that was it,, what a dum *** ... cheers again ...

please note that your help is fully appreciated



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum