Solved

vbscript setting innerHTML

Posted on 2010-09-08
4
2,194 Views
Last Modified: 2012-08-13
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
Comment
Question by:chris_desborough
4 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 125 total points
Comment Utility
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
 
LVL 3

Expert Comment

by:Marbleman
Comment Utility
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
 
LVL 11

Assisted Solution

by:govindarajan78
govindarajan78 earned 125 total points
Comment Utility
<%@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
 
LVL 1

Author Closing Comment

by:chris_desborough
Comment Utility
Thanks all. Both of your suggestions pointed me in the right direction.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now