473,385 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

having true/false trouble with visibility of DIV

In the first version of this function, I only test for true or false,
on a global var, without limiting that true or false to the id of a
particular item. What this meant was that if you were using this
function for several items on a page, sometimes you had to click twice
and other times you only had to click once, because sometimes
visibility was false though you were clicking on an item that was true.
So then I started adding the id's of each item on a page to the object
isDivVisible. My goal was that the true/false status of visibility
should be specific to each item. Yet I find I'm still having to click
twice. Where is the flaw in the logic of the code I wrote?

isDivVisible = new Object();
function hideOrShowDiv(elementPointer) {
var divId = elementPointer.id;
if (document.getElementById(divId)) {
var optionDiv = document.getElementById(divId);

// 12-30-04 - we need isDivVisible to remember a different
// visibility state for each div on the page, so we use
// Javascript's hash-like syntax to keep track of each
// div as if the various states were being stored in an array

if (isDivVisible.divId) {
if (isDivVisible["divId"] == true) {
optionDiv.style.visibility='hidden';
optionDiv.style.height='0px';
optionDiv.style.width='0px';
optionDiv.style.overflow='auto';
optionDiv.style.display='none';
isDivVisible["divId"] = false;
} else {
optionDiv.style.visibility='visible';
optionDiv.style.height='auto';
optionDiv.style.width='auto';
optionDiv.style.overflow='auto';
optionDiv.style.display='block';
isDivVisible["divId"] = true;
}
} else {
optionDiv.style.visibility='visible';
optionDiv.style.height='auto';
optionDiv.style.width='auto';
optionDiv.style.overflow='auto';
optionDiv.style.display='block';
isDivVisible["divId"] = true;
}
}
}

Jul 23 '05 #1
1 1767
On 3 Jan 2005 10:15:27 -0800, <lk******@geocities.com> wrote:

[snip]
Where is the flaw in the logic of the code I wrote?


You're not actually using the value of the id with your "hash table".
Please re-read
<URL:http://groups.google.co.uk/groups?as_umsgid=opsjv499dbx13kvk%40atlantis>.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ed | last post by:
i'm having trouble with a form. I want to be able to type in the address of the form with the data for the form items in the URL (ie: http://somesite.com/formpage.html?field1=data1&field2=data2)....
9
by: TD | last post by:
I am trying to add transactions to my code. The original code worked fine until I followed an example to setup transactions, now the code does strange things, but no error messages. Could...
1
by: Michael Evanchik | last post by:
im trying to do a get on a http server and keep appending the return data to a string and then i even tried an array of strings. But very odd things are happening. I am completely missing the...
6
by: Nick Stansbury | last post by:
Hi, I have a loop running on Page_PreRender that sets a number of controls to invisible based on a set of criteria. Before I do this however, I set all of the drop down lists to be visible with...
90
by: John Salerno | last post by:
I'm a little confused. Why doesn't s evaluate to True in the first part, but it does in the second? Is the first statement something different? False print 'hi' hi Thanks.
71
by: David T. Ashley | last post by:
Where is the best place to define TRUE and FALSE? Are they in any of the standard include files, ever? Do any standards apply? What I've traditionally done is something like: #ifndef...
1
by: The Menace | last post by:
I have a problem that I've been trying to figure out. I have several controls on the page and depending on the selection on the drop down list, the visibility is set to control to true (set to...
8
by: cutlass | last post by:
Need you assistance to anyone who is willing to offer. I have been working on this script and can't get it to work. The issue I'm having is the statement: function validateSender($Address)...
2
by: fuyumi87 | last post by:
Hi, I am currently making a list, where users can click the Add-button to add stuffs to the list, and click the Delete-button to delete the selected item. However, because it starts with an Empty...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.