Solved

vbscript setting innerHTML

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

21 Experts available now in Live!

Get 1:1 Help Now