Solved

vbscript setting innerHTML

Posted on 2010-09-08
4
2,449 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 83

Accepted Solution

by:
Dave Baldwin earned 125 total points
ID: 33632196
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
ID: 33632222
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
ID: 33637023
<%@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
ID: 33666699
Thanks all. Both of your suggestions pointed me in the right direction.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

829 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