• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3239
  • Last Modified:

vbscript setting innerHTML

I've been led to believe that vbscript can access the DOM but keep getting a message:

Microsoft VBScript runtime error '800a01a8'  - Object required: ''

Have tried the attached code but it no good.






<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<body>
<table>
  <tr>
     <td><span id="celldiv1"></span></td>

  </tr>
</table>
<%
'set obj1 = document.GetElementByID("celldiv1")
'obj1.innerHTML = "something"
document.getElementById("celldiv1").innerHTML = "something"
 %>
</body>
</html>

Open in new window

0
chris_desborough
Asked:
chris_desborough
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
That's VBscript for ASP on the server.  VBscript in the browser uses script tags.  This page gives some examples: http://www.herongyang.com/VBScript/IE-Browser-VBScript-Support-Introduction.html  The first example works in IE6.  Remember that VBscript only works in IE.
0
 
MarblemanCommented:
You are mixing something up here:

You cannot access the DOM from ASP code... it is executed on the the server!


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'this runs on the server, before the code is delivered to the browser
test="something"

%>
<script language="javascript" >

//this runs on the client (browser)
function changeText(){
document.getElementById("celldiv1").innerHTML = "something new";
}

</script>
<body>
<table>
  <tr>
     <td onclick="changeText()"><span id="celldiv1"><% = test %></span></td>

  </tr>
</table>

</body>
</html>

Open in new window

0
 
govindarajan78Commented:
<%@LANGUAGE="VBSCRIPT"%>

<body>
<table>
  <tr>
     <td><span id="celldiv1"></span></td>

  </tr>
</table>
<script type="text/javascript">
document.getElementById("celldiv1").innerHTML = "<%response.write("something")%>"
 </script>
</body>
</html>
0
 
chris_desboroughAuthor Commented:
Thanks all. Both of your suggestions pointed me in the right direction.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now