Avatar of chris_desborough
chris_desborough
Flag for Australia asked on

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

ASPVB Script

Avatar of undefined
Last Comment
chris_desborough

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Dave Baldwin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Marbleman

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

SOLUTION
govindarajan78

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
chris_desborough

ASKER
Thanks all. Both of your suggestions pointed me in the right direction.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck