PDA

View Full Version : move table row in Netscape


markivs
04-23-2003, 02:57 PM
Hello,
I am trying to move a table row.
With IE6.0 I am able to use 'moveRow' function.
But it dosen't work in Netscape 7.0

Dose anyone know a work around to this problem ?

My code is quite complicated but Please take a look at
the sample code that works in IE6.0

Your help will be greatly appreciated.

Thanks in advance.

Mark

<SCRIPT>
function fnMove(){
oTable.moveRow(0,1);
}
</SCRIPT>
<INPUT TYPE="button" VALUE="Change Rows" onclick="fnMove()">
<TABLE ID="oTable">
<TR><TD>Cell 1, Row 1</TD></TR>
<TR><TD>Cell 1, Row 2</TD></TR>
</TABLE>

brothercake
04-23-2003, 03:11 PM
Can you show use the code you're working with.

Roy Sinclair
04-23-2003, 05:19 PM
Also be explicit and tell us you're talking about Netscape 6 or 7 and not Netscape 4 because if you're talking about Netscape 4 the answer is forget about it.

markivs
04-23-2003, 05:44 PM
I have updated my question. Sorry for being vague the first time.

liorean
04-23-2003, 06:37 PM
function fnMove(iOrgIndex,iNewIndex){
var
oTRs=document.getElementById('oTable').getElementsByTagName('tr'),
oElement=[oTRs[iOrgIndex]];
oElement.parentNode.insertBefore(oElement,++iNewIndex<oTRs.length?oTRs[iNewIndex]:null)
}

Try that instead - it might work. (It's untested)

markivs
04-24-2003, 10:35 PM
THANKS. It kinda solves my problem. But immediately I got stuck again. Basically what I am doing is drag and drop of table rows in NS6. That's the reason I asked the question about moving table rows.

The problem is..
I drag something from a table row and drop it on an another row.
I want to find which row I dropped on.

For example, Let's assume I drag something from row1 and drop it on row3. I call the dragEnd function on 'onmouseup' event. The desired behavior would be that the dragEnd function would return me the row3. Instead it always returns me row1.

Please see the strip down verison of my code...
document.onmousedown = dragStart;
document.onmouseup = dragEnd;

function dragStart(e) {
/*this function basically gets the content of row1 and puts it inside a div.*/

document.onmousemove = dragMove;
}

function dragMove(e) {
//**I basically move the div whereever the mouse moves
(provided left mouse button is down).**//
}

function dragEnd(e) {
window.event = e;
window.event.srcElement = e.target;
window.alert(window.event.target.id);

//**** this alert always returns row1 instead of row3. Meaning somehow it always returns the row where 'onmousedown' event had occured ***//

document.onmousemove = null;
}

Any help with problem will be greatly appreciated.

Thanks.
Mark

liorean
04-24-2003, 10:42 PM
Does relatedTarget match what you want? <http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-eventgroupings-mouseevents-h3>

markivs
04-25-2003, 06:03 PM
Hi,
Thanks for your response.
relatedTarget didn't seem to solve my problem.
To make my question more clear, I have posted it again under subject: onmouseup event in NS 6

Can you please take a look at it ?

Thanks.
Mark