I have a classic ASP website, we have taken the Flash components to generate charts to incorporate this functionality through a JavaScript library.
On the same page ASP, we read text files, the data is saved in arrays and these must be passed to the javascript function. This code is not a function, because depending on the selected menu, different files are read. It is a very extensive code.
<%
···
ReDim LisOp (numop)
ReDim Lisco (numop)
ReDim LisVo (numop)
aux = options
for i = 1 to numop
p = InStr (aux, ",")
if p> 0 Then
LisOp (i - 1) = Left (aux, (p - 1))
Right aux = (aux, (Len (aux) - p))
else
LisOp (i - 1) = aux
aux = ""
end if
Next
···
%>
In these variables LisOp, Lisco, LisVo we have data. The problem is when I want to pass this information to javascript:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV = "refresh" CONTENT = "<% = TieRefresco%>">
<script type="text/javascript" src="http://www.google.com/jsapi"> </ script>
<script language="JavaScript">
google.load ('visualization', '1 ', {' packages': ['table', 'corechart']});
google.setOnLoadCallback (draw);
function draw () {
var options = {title:'',
legend: {position: "none"},
hAxis: {textstyle: {color: 'black', fontName: 'Arial Black', size: 16}}
};
// Create data table object
var google.visualization.DataTable datat = new (); / / DataTable Roles
// Define columns
datat.addColumn ('string', '<% = tOpciones%>'); / / Implicit domain column.
datat.addColumn ('number', '<% = tVotos%>'); / / Implicit data column.
datat.addColumn ({type: 'string' role: 'style'});
datat.addColumn ({type: 'string' role: 'annotation'});
for (var i = 0; i << numop%% => -1, i + +) {
datat.addRow (['OP1', 450, 'color: green', '450 ']);
}
···
</ Script>
</ HEAD>
<BODY>
···
In the example I've left fixed values to the function addRow, but I need to pass the arrays created in Visual Basic script “LisOp, LisVo, LisCo”. With fixed values runs perfect. Then I put code examples I've tried but have not worked to pass array values to function addRow:
I tried the VBArray (arrayObj) toArray () function; but it gives me an error and I did not make the graphic:
var arrayObj;
var jsArray;
arrayObj = LisOp
jsArray = VBArray (arrayObj) toArray ().;
for (var i = 0; i << numop%% => -1, i + +) {
datat.addRow ([jsArray[i], 450, 'color: green', '450 ']);
}
I tried to make the loop for VBScript within the draw() function but does not work:
<% For i = 0 to numop%>
datat.addRow ([<%=LisOp(i)%>, <%=LisVo(i)%>, <%=lisCo(i)%>, <%=LisVo(i)%>])
<% Next%>
Any idea?