473,757 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

basic help needed to hiding and showing div

mt
In a nutshell, I'd like to have a list of items, each of which fills out a
small table which displays some info about a particular item(the items being
a trouble ticket for a tech support ASP-built web-based app). There may be
zero, one, or many of these per ticket. Since some tickets have many of
these items (call them work items), the page can get awful long. I have this
part working already.

So my proposed solution to make the pages shorter would be to have one line
for each of these little work items. If you click the text in that one line,
it shows what had been a hidden div. If you click it again, it hides it.

See below:

Current version:
<Main Table containing initial Ticket info>
<small table for work item #1, taking up 5 or so rows of space>
<small table for work item #2, taking up 5 or so rows of space>
<small table for work item #3, taking up 5 or so rows of space>
<small table for work item #4, taking up 5 or so rows of space>
<small table for work item #5, taking up 5 or so rows of space>

Proposed version:
<Main Table containing initial Ticket info>
<1 Line of text with brief description of item #1>
<hidden><smal l table for work item #1, taking up 5 or so rows of space>
<1 Line of text with brief description of item #2>
<hidden><smal l table for work item #2, taking up 5 or so rows of space>
<1 Line of text with brief description of item #3>
<hidden><smal l table for work item #3, taking up 5 or so rows of space>
<1 Line of text with brief description of item #4>
<hidden><smal l table for work item #4, taking up 5 or so rows of space>
<1 Line of text with brief description of item #5>
<hidden><smal l table for work item #5, taking up 5 or so rows of space>
Additionally, I'd like to come up with an "Expand all" and Contract all"
link or button for the whole page.

My thinking is that the way to do it would be to have a simple javascript
function which would change the styles from display:none to display:block,
and call that function with an OnClick event on that text. I guess I'm not
sure how to code that, and that's the help I'm asking for.
Jul 23 '05 #1
5 1549
"mt" <mi********@HTO mail.com> wrote in message
news:le******** ************@co mcast.com...
In a nutshell, I'd like to have a list of items, each of which fills out a
small table which displays some info about a particular item(the items being a trouble ticket for a tech support ASP-built web-based app). There may be
zero, one, or many of these per ticket. Since some tickets have many of
these items (call them work items), the page can get awful long. I have this part working already.

So my proposed solution to make the pages shorter would be to have one line for each of these little work items. If you click the text in that one line, it shows what had been a hidden div. If you click it again, it hides it.

See below:

Current version:
<Main Table containing initial Ticket info>
<small table for work item #1, taking up 5 or so rows of space>
<small table for work item #2, taking up 5 or so rows of space>
<small table for work item #3, taking up 5 or so rows of space>
<small table for work item #4, taking up 5 or so rows of space>
<small table for work item #5, taking up 5 or so rows of space>

Proposed version:
<Main Table containing initial Ticket info>
<1 Line of text with brief description of item #1>
<hidden><smal l table for work item #1, taking up 5 or so rows of space>
<1 Line of text with brief description of item #2>
<hidden><smal l table for work item #2, taking up 5 or so rows of space>
<1 Line of text with brief description of item #3>
<hidden><smal l table for work item #3, taking up 5 or so rows of space>
<1 Line of text with brief description of item #4>
<hidden><smal l table for work item #4, taking up 5 or so rows of space>
<1 Line of text with brief description of item #5>
<hidden><smal l table for work item #5, taking up 5 or so rows of space>
Additionally, I'd like to come up with an "Expand all" and Contract all"
link or button for the whole page.

My thinking is that the way to do it would be to have a simple javascript
function which would change the styles from display:none to display:block,
and call that function with an OnClick event on that text. I guess I'm not sure how to code that, and that's the help I'm asking for.

Something like the following? Watch for word-wrap.

<html>
<head>
<title>showhide .htm</title>
<script type="text/javascript">
function showhide(what) {
if (what == "") {
var disp = document.getEle mentById("Disp" ).value;
disp == "Show" ? disp = "Hide" : disp = "Show";
disp == "Show" ? stat = "none" : stat = "block";
var divs = document.getEle mentsByTagName( "div");
var divx;
for (var i=0; i<divs.length; i++) {
divx = divs[i].id;
document.getEle mentById(divx). style.display = stat;
}
document.getEle mentById("Disp" ).value = disp;
} else {
var stat = document.getEle mentById(what). style.display;
if (stat == "none") {
document.getEle mentById(what). style.display = "block";
} else {
document.getEle mentById(what). style.display = "none";
}
}
}
</script>
</head>
<body>
<table border="0" width="400" style="border:s olid 1px black">
<tr>
<th width="50">Tick et<hr></th>
<th width="350">Pro blem Description<hr> </th>
</tr>
<tr valign="top">
<td align="center">
<a href="#" onclick="showhi de('Tix1')">#1</a>
</td>
<td>
Broken Pipe
<div id="Tix1" style="display: none">
blah, blah, blah, blah, blah, blah.
</div>
</td>
</tr>
<tr valign="top">
<td align="center">
<a href="#" onclick="showhi de('Tix2')">#2</a>
</td>
<td>
Broken Window
<div id="Tix2" style="display: none">
blah, blah, blah, blah, blah, blah.
</div>
</td>
</tr>
</table>
<br>
<input type="button" name="Disp" value="Show" onclick="showhi de('')">
</body>
</html>
Jul 23 '05 #2

Here is another version of McK's effort. The differences are that
doesn't hide the divs with in-line styles to begin with, so if the user
has JS turned off, they will still see the page content.

I've also added show all and hide all functions, which could be one
function called with an argument of "none" or "all" perhaps.

I've isolated the ticket divs from others in the page by putting them
inside a div id="tickets", then pass this to the hideAll & showAll
functions. It limits their scope so they don't hide all the child divs
in the page.

Of course you can have lots of fun with styles, etc. and use tables to
do layout, but divs and CSS may be simpler.

Have fun!

<html>
<head>
<title>showhi de 2</title>

<style type="text/css">
..head
{font-family: arial, sans-serif;
font-size: 14;
padding: 10 0 0 5
}
..items
{padding: 0 0 0 10;
border-bottom: 1 solid #003366;
border-left: 2 solid #003366;
}
..item
{font-size: 12;
margin: 0 0 0 0
}
</style>

<script type="text/javascript">

function showHide2(a) {
var b = a.parentNode.ge tElementsByTagN ame('div');
for (var i=0; i<b.length; ++i) {
if (b[i].style.display == 'none') {
b[i].style.display = '';
} else {
b[i].style.display = 'none';
}
}
}

function hideAll2(x) {
var c = x.getElementsBy TagName('div');
for (var j=0; j<c.length; ++j) {
var d = c[j].getElementsByT agName('div');
for (var k=0; k<d.length; ++k) {
d[k].style.display = 'none';
// alert(d[k].style);
}
}
}
function showAll2(x) {
var c = x.getElementsBy TagName('div');
for (var j=0; j<c.length; ++j) {
var d = c[j].getElementsByT agName('div');
for (var k=0; k<d.length; ++k) {
d[k].style.display = '';
}
}
}

</script>
</head>
<body onload="hideAll 2(document.getE lementById('tic kets'))">

<br><br>
<form action="">
<input type="button" value="Show all 2"
onclick="showAl l2(document.get ElementById('ti ckets'));">
<input type="button" value="Hide all 2"
onclick="hideAl l2(document.get ElementById('ti ckets'));">
</form>

<div id="tickets">
<div class="head"><a href="#" onclick="showHi de2(this);">Bro ken Pipe</a>
<div class="items">
<p class="item">At tend site to stop leakage</p>
<p class="item">Ha rry's Hardware at (some address) has
replacement parts</p>
<p class="item">Fi x ASAP - charge to charge code 7</p>
</ol>
</div>
</div>
<div class="head"><a href="#" onclick="showHi de2(this);">Rep air window</a>
<div class="items">
<p class="item">Gl azier on site, needs immediate assistance</p>
<p class="item">En sures WHS standards observed - sharp glass</p>
<p class="item">Ha ve fun</p>
</div>
</div>
<div class="head"><a href="#" onclick="showHi de2(this);">Wif e's birthday</a>
<div class="items">
<p class="item">Do n't forget</p>
<p class="item">Je welry is nice, diamonds preferred</p>
<p class="item">Fl owers to her work (BIG bunch), with soppy card</p>
<p class="item">Di nner, then whatever...</p>
</div>
</div>
</div>
</body>
</html>
Jul 23 '05 #3
mt
Thanks! I'll try it out!
Jul 23 '05 #4
mt
Thanks! I will see what I can do with this.
Jul 23 '05 #5
On Sat, 09 Oct 2004 23:26:18 GMT, McKirahan <Ne**@McKirahan .com> wrote:
var divs = document.getEle mentsByTagName( "div");
var divx;
for (var i=0; i<divs.length; i++) {
divx = divs[i].id;
document.getEle mentById(divx). style.display = stat;
As you already have the element reference, why find the id and obtain that
reference all over again?

[snip]
<div id="Tix1" style="display: none">
[snip]
<div id="Tix2" style="display: none">


Considering that the OP is working on a technical support page, that
doesn't seem to be a particularly sensible idea. A page should be usable
without scripting, but enhanced by its presence. It should not be the
other way around.

[snip]

Mike

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

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

Similar topics

7
9290
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. # No warranty express or implied for the accuracy, fitness to purpose
2
2224
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups of searchable fields in the fields 3. Each group can be expanded/collapsed by clicking on a link "(Fewer|More) Options" which sits right next to the group title.
2
1427
by: EventListener | last post by:
I have a folder/file tree that is dynamically generated from an xml file. The way I've written it seems to work. Since I'm a fairly novice javascript programmer, I'm concerned that there may be a hidden downside to coding this way vs. hiding/showing using style.visibility. My tree starts with only the top level folders showing. When the xml for the tree loads, I have a recursive function that creates subtrees for each folder, then saves...
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
2
1212
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...
11
3183
by: Alex | last post by:
Hello all, I have a main form(say "form1") .i want to display another form(say "form2") on occuring of an event (say a button click) and want to hide it after some time so that it will again displays while occuring of the same event.I develop it by creating an object of the form2 and displays it in the event by calling form2.Show() and hide it by calling form2.Hide(). the problem is that while displaying the form2 the memory usage of...
2
1655
by: =?Utf-8?B?Sm9zaCBTY2htaWR0?= | last post by:
I have a gridview that is being used for managing inventory. The default view shows the stock currently available. When editing I don't want the stock to be directly edited, rather the user will enter the amount of items being added/removed. When the user clicks the 'Edit' link I want to hide the stock column and display a field for the TransactionAmt. I'm using the RowUpdating event to execute some functions used by that field. I've...
12
1972
by: Ste | last post by:
Hi there, I've got a website with a list of Frequently Asked Questions, so there's a question and answer in a long list down the page. Can anyone recommend a simple script that would allow me to hide each answer when the page loaded, but then made them individually appear/disappear when clicking the question? I'm after a solution that will degrade gracefully if a page doesn't
17
2020
by: rohitchawla | last post by:
i am trying to show and hide a div when onmouseover and onmouseover another div element. i am setting a setTimeout duration on onmouseout to delay the hiding of div for around two second The problem is that when i mouseover an element and then onmouseout it and then back again mouseovers that element before the timeout, the element still gets hidden so i put a flag=1 when i mouseover the element and flag=0 at mouseout and checked the value...
4
1737
Fane
by: Fane | last post by:
I have a label in program showing that the textbox's text is copied to clipboard. At the start it is not visible, but after the button is clicked, it becomes visible. After this I would want it to become not visible when you click anywhere on the program (form, textbox...). How can I do this?
0
9487
marktang
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...
0
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
jinu1996
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...
1
9884
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,...
0
9735
tracyyun
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...
0
8736
agi2029
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...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.