Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert Elements

Status
Not open for further replies.

yarsu

Technical User
Dec 5, 2001
3
AE
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=&quot;jscript&quot;>

function Disp() {
var movethis, moveb4, p;
movethis = document.all(&quot;seg03&quot;);
moveb4 = movethis.previousSibling;
p = movethis.parentElement;
p.insertBefore(movethis,moveb4);
}

</script>

<script language=&quot;VBScript&quot;>

Sub Mve()

Dim movethis
dim moveb4
dim p
dim temp

set movethis = document.all(&quot;seg03&quot;)
set moveb4 = movethis.previousSibling
set p = movethis.parentElement
p.insertBefore movethis,moveb4


End Sub

</script>

</head>
<body>
<TABLE STYLE=&quot;backgound-color:#9BCD9B; top: 100px&quot; ID=&quot;tbl&quot; border=&quot;1&quot;>

<TR id=&quot;seg01&quot;>
<td>1</td><td>a</td><td>a</td>
</TR>
<TR id=&quot;seg02&quot;>
<td>2</td><td>b</td><td>b</td>
</TR>
<TR id=&quot;seg03&quot;>
<td>3</td><td>c</td><td>c</td>
</TR>

</TABLE>
<BUTTON OnClick=&quot;Disp()&quot;>Move Up (JS)</BUTTON>
<BUTTON OnClick=&quot;Mve()&quot;>Move Up (VB)</BUTTON>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top