473,473 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Strange JavaScript Behavior

I have a page with two dynamic tables. One is a master list of items
for selection. The second is a list of selected items.

The master list contains 4 columns.
1) The item code - hidden
For example NY
2) The item descrtion - visible
For example, New York
3) The item type - hidden
For example, state_country
4) The item type description - hidden
For example State
<table class="contenttable" cellspacing="0" cellpadding="0" rules="all"
bordercolor="#DADADA" border="2" id="_ctl0_searchResultsDataGrid"
style="border-color:#DADADA;border-width:2px;border-style:Solid;border-collapse:collapse;">
<tr class="columnheader">
<td class="hide">Code2</td><td>Name</td><td
class="hide">Code1</td><td class="hide">Type</td>
</tr>
<tr class="odd"
ondblclick="javascript:MoveSelectedItemToDestinati onGrid('_ctl0_searchResultsDataGrid','_ctl0_select edResultsDataGrid','_ctl0_selectedResultsDataGrid' ,'_ctl0_selectedResults')"
onclick="javascript:SingleClickToMarkRowForSelecti on(this, event);"
onmouseover="javascript:HighlightRow(this);"
onmouseout="javascript:UnHighlightRow(this);">
<td class="hide">6020</td><td>Aerospace/Defense</td><td
class="hide">Micro</td><td class="hide">Micro Industry</td>
</tr>
....
</table>

The list of selected items is identical except that the last column,
item type description, is visible.
<table class="contenttable" cellspacing="0" cellpadding="0" rules="all"
bordercolor="#DADADA" border="2" id="_ctl0_selectedResultsDataGrid"
style="border-color:#DADADA;border-width:2px;border-style:Solid;border-collapse:collapse;">
<tr class="columnheader">
<td class="hide">Code2</td><td>Name</td><td
class="hide">Code1</td><td>Type</td>
</tr>
....
</table>

When you double click on an item, it moves it from the master list to
the list of selected items. When you double click on the list of
selected items it move the item back to the master list. When you
double click an item, the items are put in the destination list
correctly, but when you double click destination list, the third and
forth columns are reversed. The first two columns are correct. It is
as if the JavaScript engine wants all the visible columns to be
contiguous.

Here is the code that updates the two lists
function MoveSelectedItemToDestinationGrid(sourceGridId,
destinationGridId, resultsGridId, hiddenFieldId)
{
var sourceGrid = document.getElementById(sourceGridId);
var destinationGrid = document.getElementById(destinationGridId);
var sourceSelectedIndexes = GetSelectedIndexes(sourceGrid.rows);

// Add to destination
if ( sourceSelectedIndexes.length > 0 )
{
for( i = 0; i < sourceSelectedIndexes.length; i++ )
{
var row = destinationGrid.insertRow(destinationGrid.rows.len gth);
row.ondblclick =
function(){MoveSelectedItemToDestinationGrid(desti nationGridId,
sourceGridId, resultsGridId, hiddenFieldId)};
row.onclick = function(){SingleClickToMarkRowForSelection(this,
event)};
row.onmouseover = function(){HighlightRow(this)};
row.onmouseout = function(){UnHighlightRow(this)};

for(j=0; j < sourceGrid.rows[0].cells.length; j++)
{
cell = row.insertCell(j);
cell.innerHTML =
sourceGrid.rows[sourceSelectedIndexes[i]].cells[j].innerHTML;
cell.className = destinationGrid.rows[0].cells[j].className;
}
}
// When you select an item, cells[2] is state_country and cells[3] is
State
// When you click on a selected item, cells[2] is State and cells[3] is
state_country
// It is as if JavaScript is lumping all the visible columns together
alert(row.cells[2].innerHTML + "|" + row.cells[3].innerHTML);

// Remove from source
var count = 0;
while ( count < sourceSelectedIndexes.length )
{
var firstIndex = GetSelectedIndex(sourceGrid.rows);
sourceGrid.deleteRow(firstIndex);
count++;
}

// Selected list when blank, has an
empty row
DeleteEmptyRow(destinationGrid);

// Preserve odd/even formatting for
rows
RepaintTable(sourceGrid);
RepaintTable(destinationGrid);

// save results as a hidden field for
form post
PopulateHiddenField( resultsGridId, hiddenFieldId );
}
}

Thanks in advance for your help.

Jan 18 '06 #1
1 1634
Try simplifying a test case before submitting to this group.

Such code as posted above will get a non-response almost every time.

JsD

Jan 20 '06 #2

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

Similar topics

2
by: swp | last post by:
I have a site created using ASP, HTML, and JavaScript. I use frames to manage a few things, and requires SSL to connect. The site is on a secured network, not meant to be cross-browser...
0
by: the friendly display name | last post by:
Hi, I have a filled multiline textbox on the site. I can scroll it with IE and Firefox, but under Opera (tested under 7.54, and Opera 8, under "identify as MSIE" and under Opera identification)...
1
by: Alexander Inochkin | last post by:
Hi! I found same strange behavior of ASP.NET. It is possible this is the bug. Follow the steps:
0
by: ivb | last post by:
Hi all, I am using DB2 8.1.11.1 on NT with ASP.NET 1.1 When application make connection to database (via ADO.NET), it set "Connection timeout" parameter to 30 seconds. After, when my webpage...
6
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
1
by: Larax | last post by:
Alright, so here's the problem. I define a global variable in my script and then add methods/properties to it. Everything works great, no error in Javascript Console. But when I refresh site,...
1
by: Nicholas Palmer | last post by:
Hi all, Got a question about the AspCompat=true page property. First a little background. We have an ASP.NET app that uses two COM components. The first is the Microsoft OWC 11 components and...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
4
by: r | last post by:
Hello, It seems delimiters can cause trouble sometimes. Look at this : <script type="text/javascript"> function isDigit(s) { var DECIMAL = '\\.'; var exp = '/(^?0(' + DECIMAL
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...
0
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,...
0
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...
1
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...
0
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.