473,382 Members | 1,313 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,382 software developers and data experts.

Show/Hide Row

3
Hi There,

I have recently started coding in ASP.NET (less than 2 weeks) and over the last day or 2 I've started using some Javascript. I have created a screen with a table and xx number of rows. All but one of the rows are shown immediately. I only want the row that is not shown to be shown (visible) based on some other data. The Javascript function runs and the row is displayed perfectly. The problem I am then faced with is that when I want to hide the row, a blank 'row' (or something) is left behind so there is the gap between the 2 visible questions. When the hidden row is made visible again, this row is shown above the blank row/line from the previous step. Doing this a few time leads to lots of blank rows/lines in the page.

I know that there has to be a way to get this working properly but with my limited time working with this language, I'm afraid that I am hitting a brink wall here and its probably something that is stupid simple ... :)

Your help will be greatly appreciated

************************************************** **********************************
function checkModelOptions(currentObject,currentDivObject)
{
var currentObject = $(currentObject);
var urlData = $("urlData");
var getContainer = currentObject.parentNode.parentNode.parentNode;
// Hide the ModelOptionsQuestion field immediately. Let the process below determine whether it should be shown
$("modelOptionsQuestion").style.display='none';
var optionContainer = $(currentDivObject);
optionContainer.hide();
if(currentObject.value != "")
{
var newUrl = "";
newUrl = getLocation() + "xxxxxxxxxx/Table.aspx?typeOfLookup=checkModelOptions&" + getDecendantsValues(getContainer);
newUrl += "&currentDivObject="+currentDivObject;
urlData.value = newUrl;
loadXMLDoc(newUrl, "");
}
}
************************************************** **********************************

************************************************** **********************************
case "checkModelOptions":
enableModelOptions(jsonObject);
break;
************************************************** **********************************


************************************************** **********************************
function enableModelOptions(jsonObject)
{
$("modelOptionsQuestion").style.display='block';
}
************************************************** **********************************
Jun 29 '07 #1
1 2318
gits
5,390 Expert Mod 4TB
hi,

have a look at the following example the uses dom-scripting-methods instead of setting styles ... that will do the job:

[HTML]
<html>
<head>
<script>
var hidden_row = null;
var next_row = null;
var parent_node = null;

function hide_row(id) {
var rows = document.getElementsByTagName('tr');

for (var i = 0; i < rows.length; i++) {
var row = rows[i];

if (row.id == id) {
hidden_row = row;
next_row = rows[i + 1];
break;
}
}

parent_node = hidden_row.parentNode;

parent_node.removeChild(hidden_row);
}

function show_hidden_row() {
parent_node.insertBefore(hidden_row, next_row);
}
</script>
</head>
<body>
<table id="my_table">
<tr id="row1">
<td>test1</td>
<td>test1</td>
<td>test1</td>
</tr>
<tr id="row2">
<td>test2</td>
<td>test2</td>
<td>test2</td>
</tr>
<tr id="row3">
<td>test3</td>
<td>test3</td>
<td>test3</td>
</tr>
</table>

<br/>

<input type="button" value="Hide row2" onclick="hide_row('row2');"/>

<input type="button" value="Show hidden row" onclick="show_hidden_row();"/>

</body>
</html>
[/HTML]

ask ... in case you need further explaination ... the script removes the row from the document-tree, but keeps a reference to it, and we may insert it back before the next sibling element (at the moment - this script only works if there is such a next sibling child-node - it relies on that! ;) in case the removed row is the last one, we have to adapt the script ;))

kind regards ...
Jun 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
0
by: Efkas | last post by:
I have a full custom application with some widged extending Controls like Label and PictureBox. I build a menu with these widgets. When I click on one of them, it calls a function to display...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.