I was trying to move the rows in a table with vbscript using InsertBefore() method. While the Javascript version works fine , vbscript throws an error "Invalid Argument". Since our Intranet uses VBScript mainly, we want to stick with VBS. Have attached sample code. HELP !!
<html>
<head>
<script language="jscript">
function Disp() {
var movethis, moveb4, p;
movethis = document.all("seg03"
moveb4 = movethis.previousSibling;
p = movethis.parentElement;
p.insertBefore(movethis,moveb4);
}
</script>
<script language="VBScript">
Sub Mve()
Dim movethis
dim moveb4
dim p
dim temp
set movethis = document.all("seg03"
set moveb4 = movethis.previousSibling
set p = movethis.parentElement
p.insertBefore movethis,moveb4
End Sub
</script>
</head>
<body>
<TABLE STYLE="backgound-color:#9BCD9B; top: 100px" ID="tbl" border="1">
<TR id="seg01">
<td>1</td><td>a</td><td>a</td>
</TR>
<TR id="seg02">
<td>2</td><td>b</td><td>b</td>
</TR>
<TR id="seg03">
<td>3</td><td>c</td><td>c</td>
</TR>
</TABLE>
<BUTTON OnClick="Disp()">Move Up (JS)</BUTTON>
<BUTTON OnClick="Mve()">Move Up (VB)</BUTTON>
</body>
</html>
<html>
<head>
<script language="jscript">
function Disp() {
var movethis, moveb4, p;
movethis = document.all("seg03"
moveb4 = movethis.previousSibling;
p = movethis.parentElement;
p.insertBefore(movethis,moveb4);
}
</script>
<script language="VBScript">
Sub Mve()
Dim movethis
dim moveb4
dim p
dim temp
set movethis = document.all("seg03"
set moveb4 = movethis.previousSibling
set p = movethis.parentElement
p.insertBefore movethis,moveb4
End Sub
</script>
</head>
<body>
<TABLE STYLE="backgound-color:#9BCD9B; top: 100px" ID="tbl" border="1">
<TR id="seg01">
<td>1</td><td>a</td><td>a</td>
</TR>
<TR id="seg02">
<td>2</td><td>b</td><td>b</td>
</TR>
<TR id="seg03">
<td>3</td><td>c</td><td>c</td>
</TR>
</TABLE>
<BUTTON OnClick="Disp()">Move Up (JS)</BUTTON>
<BUTTON OnClick="Mve()">Move Up (VB)</BUTTON>
</body>
</html>