I can display and hide 1 object at a time, but haven't seen it done on
multiple objects simultaneously. I have four (or more) tables on a
page that start off hidden, and I want to toggle their visibility --
but have only one table visible at any time.
If I click button #1, table #1 should toggle visibility and all other
tables should remain hidden. If table #1 is visible and I click button
#3, table #1 becomes hidden and table #3 becomes visible.
My code loops through an array, but the loop only runs twice. I've
resisted using cookies because too many people block them. If someone
could tell me where I'm going wrong with this code, I'd greatly
appreciate it.
function toggleText(togg leObj) {
var myObj = document.getEle mentById(toggle Obj); // what we click
var currObj; // this gets used in the loop
var i;
// create an array item for each table we want to toggle
var textStuff = new Array();
textStuff[0]= 'itemOne';
textStuff[1]= 'itemTwo';
textStuff[2]= 'itemThree';
textStuff[3]= 'itemFour';
// loop through the array to look at each object on the page
// right now, the loop only runs twice -- I tested it with Alerts
for(i = 0; i<textStuff.len gth; i++) {
// the array item we're currently looping on will get some tests
currObj = textStuff[i];
// find the value of the object in the current loop
switch(currObj) {
// if the current object is the one we just clicked, then...
case myObj.id:
// if it isn't hidden, hide it
if (myObj.style.di splay != 'none') {
myObj.style.dis play = 'none';
}
// if it is hidden, unhide it
else {
myObj.style.dis play = '';
}
// if the current object is one we didn't click, then...
case != myObj.id:
// hide it, because we didn't click it
currObj.style.d isplay = 'none';
} // end of switch
} // end of loop
} // end of function
I'm using it on the page this way:
<a href="javascrip t:toggleText('i temOne');">
<img src="button.gif " /></a>
<table id="itemOne" style="display: none">
(and 3 more like this further down the page with corresponding names) 2 2019
"Severus Snape" <sn***@hogwarts .eduwrote in message
news:ig******** *************** *********@4ax.c om...
>I can display and hide 1 object at a time, but haven't seen it done on
multiple objects simultaneously. I have four (or more) tables on a
page that start off hidden, and I want to toggle their visibility --
but have only one table visible at any time.
If I click button #1, table #1 should toggle visibility and all other
tables should remain hidden. If table #1 is visible and I click button
#3, table #1 becomes hidden and table #3 becomes visible.
My code loops through an array, but the loop only runs twice. I've
resisted using cookies because too many people block them. If someone
could tell me where I'm going wrong with this code, I'd greatly
appreciate it.
function toggleText(togg leObj) {
var myObj = document.getEle mentById(toggle Obj); // what we click
var currObj; // this gets used in the loop
var i;
// create an array item for each table we want to toggle
var textStuff = new Array();
textStuff[0]= 'itemOne';
textStuff[1]= 'itemTwo';
textStuff[2]= 'itemThree';
textStuff[3]= 'itemFour';
// loop through the array to look at each object on the page
// right now, the loop only runs twice -- I tested it with Alerts
for(i = 0; i<textStuff.len gth; i++) {
// the array item we're currently looping on will get some tests
currObj = textStuff[i];
// find the value of the object in the current loop
switch(currObj) {
// if the current object is the one we just clicked, then...
case myObj.id:
// if it isn't hidden, hide it
if (myObj.style.di splay != 'none') {
myObj.style.dis play = 'none';
}
// if it is hidden, unhide it
else {
myObj.style.dis play = '';
}
// if the current object is one we didn't click, then...
case != myObj.id:
// hide it, because we didn't click it
currObj.style.d isplay = 'none';
} // end of switch
} // end of loop
} // end of function
I'm using it on the page this way:
<a href="javascrip t:toggleText('i temOne');">
<img src="button.gif " /></a>
<table id="itemOne" style="display: none">
(and 3 more like this further down the page with corresponding names)
"Severus Snape" <sn***@hogwarts .eduwrote in message
news:ig******** *************** *********@4ax.c om...
>I can display and hide 1 object at a time, but haven't seen it done on
multiple objects simultaneously. I have four (or more) tables on a
page that start off hidden, and I want to toggle their visibility --
but have only one table visible at any time.
If I click button #1, table #1 should toggle visibility and all other
tables should remain hidden. If table #1 is visible and I click button
#3, table #1 becomes hidden and table #3 becomes visible.
My code loops through an array, but the loop only runs twice. I've
resisted using cookies because too many people block them. If someone
could tell me where I'm going wrong with this code, I'd greatly
appreciate it.
function toggleText(togg leObj) {
var myObj = document.getEle mentById(toggle Obj); // what we click
var currObj; // this gets used in the loop
var i;
// create an array item for each table we want to toggle
var textStuff = new Array();
textStuff[0]= 'itemOne';
textStuff[1]= 'itemTwo';
textStuff[2]= 'itemThree';
textStuff[3]= 'itemFour';
// loop through the array to look at each object on the page
// right now, the loop only runs twice -- I tested it with Alerts
for(i = 0; i<textStuff.len gth; i++) {
// the array item we're currently looping on will get some tests
currObj = textStuff[i];
// find the value of the object in the current loop
switch(currObj) {
// if the current object is the one we just clicked, then...
case myObj.id:
// if it isn't hidden, hide it
if (myObj.style.di splay != 'none') {
myObj.style.dis play = 'none';
}
// if it is hidden, unhide it
else {
myObj.style.dis play = '';
}
// if the current object is one we didn't click, then...
case != myObj.id:
// hide it, because we didn't click it
currObj.style.d isplay = 'none';
} // end of switch
} // end of loop
} // end of function
I'm using it on the page this way:
<a href="javascrip t:toggleText('i temOne');">
<img src="button.gif " /></a>
<table id="itemOne" style="display: none">
(and 3 more like this further down the page with corresponding names)
The problem you have is one of a collection of tables, only one of which
should be visible at any one time, depending in which button has been
pressed. One way of doing it is simply turning all the relevant table's
visibility off, and the one table who's id matches the value passed, on - as
below:
function toggleText(togg leObj)
{
var textStuff = [ 'itemOne', 'itemTwo', 'itemThree', 'itemFour' ];
for( var i = 0; i < textStuff.lengt h ; i++ )
document.getEle mentById(id).st yle.display = (toggleObj == textStuff[i] ?
'inline' : 'none');
}
--
AKA "Dobbie The House Elf" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Marc |
last post by:
Hi all,
I am trying to write an application where I need the ability to open
an Excel spreadsheet and do basic read/write, insert rows, and
hide/unhide rows. Using win32com I have been able to get the basics
down as well as some examples displaying how to simply read and write.
But the next step appears exponential. I haven never done anything in
VB, so any and all concepts and commands are completely foreign. I
have been digging...
|
by: Ben Thomas |
last post by:
Hi all,
I'm having some trouble understanding the behavior of std::ostringstream.
(I'm using Visual Studio .Net & STL port 4.5.3). I'll appreciate if someone
can give me a little explanation of this behavior and how it is possible...
Here's my code
//////////////////////////
#include <stdio.h>
|
by: WindAndWaves |
last post by:
Hi Gurus
I have a page, which looks a bit like this:
....
<body>
<div ID=id1>................</DIV>
<div ID=gsd>................</DIV>
<div ID=ewd>................</DIV>
<div ID=fac>................</DIV>
|
by: Darius |
last post by:
I'm writing here in hopes that someone can explain the difference
between the new and virtual/override keywords in C#.
Specifically, what is the difference between this:
public class Window
{
public void Draw()
{
Console.WriteLine("The WINDOW Draw method is
running!");
|
by: darrel |
last post by:
When showing/hiding items on the front end via codebehind, one normally just
sets the object to runat='server' and then set's its visibility to false.
This works fine. However, when I have a 'set' of items that are scattered
all around the page, having to explicitely set each individual item to
true/false can get a bit tedious. Is there a more efficient method for
hiding a variety of items at once?
I can do this via javascript if I set...
| |
by: Noel |
last post by:
Hello,
I'm currently developing a web service that retrieves data from an employee
table. I would like to send and retrieve a custom employee class to/from the
webservice. I have currently coded the custom employee class and have built
it as a separate library (employee.dll). This employee.dll is being
referenced by both the web service and the windows application.
I face the following problem when I send this class to the webservice.
|
by: Ray |
last post by:
I just moved to another company that's mainly a Java/.NET shop. I was
happy to find out that there's a movement from the grassroot to try to
convince the boss to use a dynamic language for our development!
Two of the senior developers, however, are already rooting for Ruby on
Rails--although they haven't tried RoR themselves. When I suggested
Django, they went like, "what's that?".
I said, "It's like the Python counterpart of RoR".
|
by: pic078 via AccessMonster.com |
last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files)
that remains stuck in task manager after exiting the application - you can't
reopen database after exiting as a result - I have read every post out there
and spent hours trying to figure out the problem with no success whatsoever -
I have constrained the problem to one form however, and I think it's hiding
somewhere in my code associated with this form, which is...
|
by: Eric IsWhoIAm |
last post by:
I have four tables created so far: Courses, Instructors, Courses and
Instructors (which shows the Course and Instructor Name fields, but holds
their IDs since those are the keys), and Students. Now, I wish to create a
Classrooms (or something similar) table which will allow me to pick the
Course from Courses and Instructors, and hold multiple Students for each
Course. I am unsure how to do this in Access.
Each student can have multiple...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |