0

I have this working in javascript, but employer wants it in VBScript. I have a series of text inputs inside cells of a table. The table was dynamically created using javascript like this:

var table = document.getElementById(tableID);
var row = table.insertRow(-1);  // Insert row at end of table
var cell1 = row.insertCell(0);  
var element1 = document.createElement("input");
element1.type = "text";
cell1.appendChild(element1);

Then elsewhere in VBScript I do this:

dim table 
set table = document.getElementById( tableID )
dim value1, value2
value1 = table.rows(1).cells(0).innerText
value2 = table.rows(1).cells(0).childNodes.innerText  ' This errors

And it does not return anything, which is strange because in javascript this works fine:

var table = document.getElementById(tableID);
var value = table.rows[1].cells[0].childNodes[0].value;

I know I'm probably making a simple mistake, but I've searched for hours and can't find how to access a dynamically created text input in a table cell.

Andy
  • 13
  • 1
  • 5
  • 1
    Shouldn't it be `.childNodes(0)`? And why does your employer want vbscript?! – bfavaretto Aug 29 '13 at 00:00
  • .childNodes(0) and .childNodes(0).innerText both throw an error expecting a function. They need VBScript for some of their clients using older legacy systems. I know it's a pain. – Andy Aug 29 '13 at 00:15
  • what is the precise error you are getting? – Jon P Aug 29 '13 at 01:34
  • the .childNodes.innerText error is "Object doesn't support this property or method". The .childNodes(0) and .childNodes(0).innerText error is "Function Expected" – Andy Aug 29 '13 at 01:38
  • My vbscript is really rusty, but try .childNodes.Item(0) or .children(0)... Why not .firstChild. Who knows how much of the DOM API is implemented in vbscript... – bfavaretto Aug 29 '13 at 01:42
  • table.rows(1).cells(0).childNodes.item(0).value did the trick! Thanks for the help @bfavaretto ! – Andy Aug 29 '13 at 02:00

0 Answers0